Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/extensions/extension_host.h

Issue 220028: Create renderers for ExtensionHosts one a time to avoid blocking the UI. (Closed)
Patch Set: scoped task factory Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/cocoa/extension_view_mac.mm ('k') | chrome/browser/extensions/extension_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
(...skipping 20 matching lines...) Expand all
31 31
32 // This class is the browser component of an extension component's RenderView. 32 // This class is the browser component of an extension component's RenderView.
33 // It handles setting up the renderer process, if needed, with special 33 // It handles setting up the renderer process, if needed, with special
34 // privileges available to extensions. It may have a view to be shown in the 34 // privileges available to extensions. It may have a view to be shown in the
35 // in the browser UI, or it may be hidden. 35 // in the browser UI, or it may be hidden.
36 class ExtensionHost : public RenderViewHostDelegate, 36 class ExtensionHost : public RenderViewHostDelegate,
37 public RenderViewHostDelegate::View, 37 public RenderViewHostDelegate::View,
38 public ExtensionFunctionDispatcher::Delegate, 38 public ExtensionFunctionDispatcher::Delegate,
39 public NotificationObserver { 39 public NotificationObserver {
40 public: 40 public:
41 class ProcessCreationQueue;
42
41 // Enable DOM automation in created render view hosts. 43 // Enable DOM automation in created render view hosts.
42 static void EnableDOMAutomation() { enable_dom_automation_ = true; } 44 static void EnableDOMAutomation() { enable_dom_automation_ = true; }
43 45
44 ExtensionHost(Extension* extension, SiteInstance* site_instance, 46 ExtensionHost(Extension* extension, SiteInstance* site_instance,
45 const GURL& url, ViewType::Type host_type); 47 const GURL& url, ViewType::Type host_type);
46 ~ExtensionHost(); 48 ~ExtensionHost();
47 49
48 #if defined(TOOLKIT_VIEWS) 50 #if defined(TOOLKIT_VIEWS)
49 void set_view(ExtensionView* view) { view_.reset(view); } 51 void set_view(ExtensionView* view) { view_.reset(view); }
50 ExtensionView* view() const { return view_.get(); } 52 ExtensionView* view() const { return view_.get(); }
(...skipping 17 matching lines...) Expand all
68 bool document_element_available() const { 70 bool document_element_available() const {
69 return document_element_available_; 71 return document_element_available_;
70 } 72 }
71 73
72 // Sets the the ViewType of this host (e.g. mole, toolstrip). 74 // Sets the the ViewType of this host (e.g. mole, toolstrip).
73 void SetRenderViewType(ViewType::Type type); 75 void SetRenderViewType(ViewType::Type type);
74 76
75 // Returns true if the render view is initialized and didn't crash. 77 // Returns true if the render view is initialized and didn't crash.
76 bool IsRenderViewLive() const; 78 bool IsRenderViewLive() const;
77 79
78 // Initializes our RenderViewHost by creating its RenderView and navigating 80 // Prepares to initializes our RenderViewHost by creating its RenderView and
79 // to this host's url. Uses host_view for the RenderViewHost's view (can be 81 // navigating to this host's url. Uses host_view for the RenderViewHost's view
80 // NULL). 82 // (can be NULL). This happens delayed to avoid locking the UI.
81 void CreateRenderView(RenderWidgetHostView* host_view); 83 void CreateRenderViewSoon(RenderWidgetHostView* host_view);
82 84
83 // Sets |url_| and navigates |render_view_host_|. 85 // Sets |url_| and navigates |render_view_host_|.
84 void NavigateToURL(const GURL& url); 86 void NavigateToURL(const GURL& url);
85 87
86 // Insert the theme CSS for a toolstrip/mole. 88 // Insert the theme CSS for a toolstrip/mole.
87 void InsertThemeCSS(); 89 void InsertThemeCSS();
88 90
89 // RenderViewHostDelegate implementation. 91 // RenderViewHostDelegate implementation.
90 virtual RenderViewHostDelegate::View* GetViewDelegate(); 92 virtual RenderViewHostDelegate::View* GetViewDelegate();
91 virtual const GURL& GetURL() const { return url_; } 93 virtual const GURL& GetURL() const { return url_; }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 virtual void HandleMouseEvent(); 133 virtual void HandleMouseEvent();
132 virtual void HandleMouseLeave(); 134 virtual void HandleMouseLeave();
133 virtual void UpdatePreferredWidth(int pref_width); 135 virtual void UpdatePreferredWidth(int pref_width);
134 136
135 // NotificationObserver 137 // NotificationObserver
136 virtual void Observe(NotificationType type, 138 virtual void Observe(NotificationType type,
137 const NotificationSource& source, 139 const NotificationSource& source,
138 const NotificationDetails& details); 140 const NotificationDetails& details);
139 141
140 private: 142 private:
143 friend class ProcessCreationQueue;
144
141 // Whether to allow DOM automation for created RenderViewHosts. This is used 145 // Whether to allow DOM automation for created RenderViewHosts. This is used
142 // for testing. 146 // for testing.
143 static bool enable_dom_automation_; 147 static bool enable_dom_automation_;
144 148
149 // Actually create the RenderView for this host. See CreateRenderViewSoon.
150 void CreateRenderViewNow();
151
145 // ExtensionFunctionDispatcher::Delegate 152 // ExtensionFunctionDispatcher::Delegate
146 // If this ExtensionHost has a view, this returns the Browser that view is a 153 // If this ExtensionHost has a view, this returns the Browser that view is a
147 // part of. If this is a global background page, we use the active Browser 154 // part of. If this is a global background page, we use the active Browser
148 // instead. 155 // instead.
149 virtual Browser* GetBrowser(); 156 virtual Browser* GetBrowser();
150 virtual ExtensionHost* GetExtensionHost() { return this; } 157 virtual ExtensionHost* GetExtensionHost() { return this; }
151 158
152 // Returns true if we're hosting a background page. 159 // Returns true if we're hosting a background page.
153 // This isn't valid until CreateRenderView is called. 160 // This isn't valid until CreateRenderView is called.
154 bool is_background_page() const { return !view(); } 161 bool is_background_page() const { return !view(); }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; 195 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;
189 196
190 // Only EXTENSION_TOOLSTRIP and EXTENSION_BACKGROUND_PAGE are used here, 197 // Only EXTENSION_TOOLSTRIP and EXTENSION_BACKGROUND_PAGE are used here,
191 // others are not hostd by ExtensionHost. 198 // others are not hostd by ExtensionHost.
192 ViewType::Type extension_host_type_; 199 ViewType::Type extension_host_type_;
193 200
194 DISALLOW_COPY_AND_ASSIGN(ExtensionHost); 201 DISALLOW_COPY_AND_ASSIGN(ExtensionHost);
195 }; 202 };
196 203
197 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_ 204 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/extension_view_mac.mm ('k') | chrome/browser/extensions/extension_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698