diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 19:33:20 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 19:33:20 +0000 |
commit | 45904e20797f8cd28a776ed0e40ba94dc4eef97e (patch) | |
tree | 00b15cd6207f993e9553313202801702b3f7b250 /chrome/browser/extensions/extension_process_manager.h | |
parent | 1cb5fbed08b85c459288c98d63cf7c3158f519a2 (diff) | |
download | chromium_src-45904e20797f8cd28a776ed0e40ba94dc4eef97e.zip chromium_src-45904e20797f8cd28a776ed0e40ba94dc4eef97e.tar.gz chromium_src-45904e20797f8cd28a776ed0e40ba94dc4eef97e.tar.bz2 |
Introducing ExtensionProcessManager. This manages the ExtensionViews to
ensure there is only 1 process per extension.
I also changed ExtensionMessageService from singleton to one instance per
Profile. This means messages can only be passed to extensions and scripts
within the same profile.
Review URL: http://codereview.chromium.org/62132
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_process_manager.h')
-rwxr-xr-x | chrome/browser/extensions/extension_process_manager.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h new file mode 100755 index 0000000..0d4048b --- /dev/null +++ b/chrome/browser/extensions/extension_process_manager.h @@ -0,0 +1,54 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ + +#include "base/ref_counted.h" + +#include <map> + +class BrowsingInstance; +class Extension; +class ExtensionView; +class GURL; +class Profile; +class SiteInstance; + +// This class controls what process new extension instances use. We use the +// BrowsingInstance site grouping rules to group extensions. Since all +// resources in a given extension have the same origin, they will be grouped +// into the same process. +// +// We separate further by Profile: each Profile has its own group of extension +// processes that never overlap with other Profiles. +class ExtensionProcessManager { + public: + static ExtensionProcessManager* GetInstance(); + + // These are public for use by Singleton. Do not instantiate or delete + // manually. + ExtensionProcessManager(); + ~ExtensionProcessManager(); + + // Creates a new ExtensionView, grouping it in the appropriate SiteInstance + // (and therefore process) based on the URL and profile. + ExtensionView* CreateView(Extension* extension, + const GURL& url, + Profile* profile); + + // Returns the SiteInstance that the given URL belongs to in this profile. + SiteInstance* GetSiteInstanceForURL(const GURL& url, Profile* profile); + private: + // Returns our BrowsingInstance for the given profile. Lazily created and + // cached. + BrowsingInstance* GetBrowsingInstance(Profile* profile); + + // Cache of BrowsingInstances grouped by Profile. + typedef std::map<Profile*, scoped_refptr<BrowsingInstance> > + BrowsingInstanceMap; + BrowsingInstanceMap browsing_instance_map_; +}; + +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PROCESS_MANAGER_H_ |