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

Side by Side Diff: extensions/browser/process_manager.h

Issue 2419943002: [DevTools] Migrate from AgentStateCallbacks to DevToolsAgentHostObserver. (Closed)
Patch Set: mac Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ 5 #ifndef EXTENSIONS_BROWSER_PROCESS_MANAGER_H_
6 #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ 6 #define EXTENSIONS_BROWSER_PROCESS_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/weak_ptr.h" 18 #include "base/memory/weak_ptr.h"
19 #include "base/observer_list.h" 19 #include "base/observer_list.h"
20 #include "components/keyed_service/core/keyed_service.h" 20 #include "components/keyed_service/core/keyed_service.h"
21 #include "content/public/browser/devtools_agent_host_observer.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "extensions/browser/event_page_tracker.h" 24 #include "extensions/browser/event_page_tracker.h"
24 #include "extensions/browser/extension_registry_observer.h" 25 #include "extensions/browser/extension_registry_observer.h"
25 #include "extensions/common/extension_id.h" 26 #include "extensions/common/extension_id.h"
26 #include "extensions/common/view_type.h" 27 #include "extensions/common/view_type.h"
27 28
28 class GURL; 29 class GURL;
29 30
30 namespace content { 31 namespace content {
(...skipping 10 matching lines...) Expand all
41 class ExtensionHost; 42 class ExtensionHost;
42 class ExtensionRegistry; 43 class ExtensionRegistry;
43 class ProcessManagerObserver; 44 class ProcessManagerObserver;
44 45
45 // Manages dynamic state of running Chromium extensions. There is one instance 46 // Manages dynamic state of running Chromium extensions. There is one instance
46 // of this class per Profile. OTR Profiles have a separate instance that keeps 47 // of this class per Profile. OTR Profiles have a separate instance that keeps
47 // track of split-mode extensions only. 48 // track of split-mode extensions only.
48 class ProcessManager : public KeyedService, 49 class ProcessManager : public KeyedService,
49 public content::NotificationObserver, 50 public content::NotificationObserver,
50 public ExtensionRegistryObserver, 51 public ExtensionRegistryObserver,
51 public EventPageTracker { 52 public EventPageTracker,
53 public content::DevToolsAgentHostObserver {
52 public: 54 public:
53 using ExtensionHostSet = std::set<extensions::ExtensionHost*>; 55 using ExtensionHostSet = std::set<extensions::ExtensionHost*>;
54 56
55 static ProcessManager* Get(content::BrowserContext* context); 57 static ProcessManager* Get(content::BrowserContext* context);
56 ~ProcessManager() override; 58 ~ProcessManager() override;
57 59
58 void RegisterRenderFrameHost(content::WebContents* web_contents, 60 void RegisterRenderFrameHost(content::WebContents* web_contents,
59 content::RenderFrameHost* render_frame_host, 61 content::RenderFrameHost* render_frame_host,
60 const Extension* extension); 62 const Extension* extension);
61 void UnregisterRenderFrameHost(content::RenderFrameHost* render_frame_host); 63 void UnregisterRenderFrameHost(content::RenderFrameHost* render_frame_host);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 void OnKeepaliveImpulseCheck(); 262 void OnKeepaliveImpulseCheck();
261 263
262 // These are called when the extension transitions between idle and active. 264 // These are called when the extension transitions between idle and active.
263 // They control the process of closing the background page when idle. 265 // They control the process of closing the background page when idle.
264 void OnLazyBackgroundPageIdle(const std::string& extension_id, 266 void OnLazyBackgroundPageIdle(const std::string& extension_id,
265 uint64_t sequence_id); 267 uint64_t sequence_id);
266 void OnLazyBackgroundPageActive(const std::string& extension_id); 268 void OnLazyBackgroundPageActive(const std::string& extension_id);
267 void CloseLazyBackgroundPageNow(const std::string& extension_id, 269 void CloseLazyBackgroundPageNow(const std::string& extension_id,
268 uint64_t sequence_id); 270 uint64_t sequence_id);
269 271
270 void OnDevToolsStateChanged(content::DevToolsAgentHost*, bool attached); 272 const Extension* GetExtensionForAgentHost(
273 content::DevToolsAgentHost* agent_host);
274
275 // content::DevToolsAgentHostObserver overrides.
276 void DevToolsAgentHostAttached(
277 content::DevToolsAgentHost* agent_host) override;
278 void DevToolsAgentHostDetached(
279 content::DevToolsAgentHost* agent_host) override;
271 280
272 // Unregister RenderFrameHosts and clear background page data for an extension 281 // Unregister RenderFrameHosts and clear background page data for an extension
273 // which has been unloaded. 282 // which has been unloaded.
274 void UnregisterExtension(const std::string& extension_id); 283 void UnregisterExtension(const std::string& extension_id);
275 284
276 // Clears background page data for this extension. 285 // Clears background page data for this extension.
277 void ClearBackgroundPageData(const std::string& extension_id); 286 void ClearBackgroundPageData(const std::string& extension_id);
278 287
279 content::NotificationRegistrar registrar_; 288 content::NotificationRegistrar registrar_;
280 289
(...skipping 11 matching lines...) Expand all
292 // Contains all active extension-related RenderFrameHost instances for all 301 // Contains all active extension-related RenderFrameHost instances for all
293 // extensions. We also keep a cache of the host's view type, because that 302 // extensions. We also keep a cache of the host's view type, because that
294 // information is not accessible at registration/deregistration time. 303 // information is not accessible at registration/deregistration time.
295 ExtensionRenderFrames all_extension_frames_; 304 ExtensionRenderFrames all_extension_frames_;
296 305
297 BackgroundPageDataMap background_page_data_; 306 BackgroundPageDataMap background_page_data_;
298 307
299 // True if we have created the startup set of background hosts. 308 // True if we have created the startup set of background hosts.
300 bool startup_background_hosts_created_; 309 bool startup_background_hosts_created_;
301 310
302 base::Callback<void(content::DevToolsAgentHost*, bool)> devtools_callback_;
303
304 ImpulseCallbackForTesting keepalive_impulse_callback_for_testing_; 311 ImpulseCallbackForTesting keepalive_impulse_callback_for_testing_;
305 ImpulseCallbackForTesting keepalive_impulse_decrement_callback_for_testing_; 312 ImpulseCallbackForTesting keepalive_impulse_decrement_callback_for_testing_;
306 313
307 base::ObserverList<ProcessManagerObserver> observer_list_; 314 base::ObserverList<ProcessManagerObserver> observer_list_;
308 315
309 // ID Counter used to set ProcessManager::BackgroundPageData close_sequence_id 316 // ID Counter used to set ProcessManager::BackgroundPageData close_sequence_id
310 // members. These IDs are tracked per extension in background_page_data_ and 317 // members. These IDs are tracked per extension in background_page_data_ and
311 // are used to verify that nothing has interrupted the process of closing a 318 // are used to verify that nothing has interrupted the process of closing a
312 // lazy background process. 319 // lazy background process.
313 // 320 //
(...skipping 16 matching lines...) Expand all
330 337
331 // Must be last member, see doc on WeakPtrFactory. 338 // Must be last member, see doc on WeakPtrFactory.
332 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_; 339 base::WeakPtrFactory<ProcessManager> weak_ptr_factory_;
333 340
334 DISALLOW_COPY_AND_ASSIGN(ProcessManager); 341 DISALLOW_COPY_AND_ASSIGN(ProcessManager);
335 }; 342 };
336 343
337 } // namespace extensions 344 } // namespace extensions
338 345
339 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_ 346 #endif // EXTENSIONS_BROWSER_PROCESS_MANAGER_H_
OLDNEW
« no previous file with comments | « extensions/browser/app_window/app_window_registry.cc ('k') | extensions/browser/process_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698