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

Side by Side Diff: apps/app_lifetime_monitor.cc

Issue 1016473002: Make LoadMonitoringExtensionHostQueue remove itself as an ExtensionHost observer at the correct tim… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another rename Created 5 years, 9 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 | « no previous file | apps/app_load_service.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 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 #include "apps/app_lifetime_monitor.h" 5 #include "apps/app_lifetime_monitor.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/notification_details.h" 9 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
11 #include "extensions/browser/app_window/app_window.h" 11 #include "extensions/browser/app_window/app_window.h"
12 #include "extensions/browser/extension_host.h" 12 #include "extensions/browser/extension_host.h"
13 #include "extensions/browser/notification_types.h" 13 #include "extensions/browser/notification_types.h"
14 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
15 15
16 namespace apps { 16 namespace apps {
17 17
18 using extensions::AppWindow; 18 using extensions::AppWindow;
19 using extensions::AppWindowRegistry; 19 using extensions::AppWindowRegistry;
20 using extensions::Extension; 20 using extensions::Extension;
21 using extensions::ExtensionHost; 21 using extensions::ExtensionHost;
22 22
23 AppLifetimeMonitor::AppLifetimeMonitor(Profile* profile) 23 AppLifetimeMonitor::AppLifetimeMonitor(Profile* profile)
24 : profile_(profile) { 24 : profile_(profile) {
25 registrar_.Add(this, 25 registrar_.Add(this,
26 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, 26 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD,
27 content::NotificationService::AllSources()); 27 content::NotificationService::AllSources());
28 registrar_.Add(this, 28 registrar_.Add(this,
29 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, 29 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
30 content::NotificationService::AllSources()); 30 content::NotificationService::AllSources());
31 registrar_.Add( 31 registrar_.Add(
32 this, chrome::NOTIFICATION_APP_TERMINATING, 32 this, chrome::NOTIFICATION_APP_TERMINATING,
33 content::NotificationService::AllSources()); 33 content::NotificationService::AllSources());
34 34
35 AppWindowRegistry* app_window_registry = 35 AppWindowRegistry* app_window_registry =
36 AppWindowRegistry::Factory::GetForBrowserContext(profile_, 36 AppWindowRegistry::Factory::GetForBrowserContext(profile_,
37 false /* create */); 37 false /* create */);
38 DCHECK(app_window_registry); 38 DCHECK(app_window_registry);
39 app_window_registry->AddObserver(this); 39 app_window_registry->AddObserver(this);
40 } 40 }
41 41
42 AppLifetimeMonitor::~AppLifetimeMonitor() {} 42 AppLifetimeMonitor::~AppLifetimeMonitor() {}
43 43
44 void AppLifetimeMonitor::AddObserver(Observer* observer) { 44 void AppLifetimeMonitor::AddObserver(Observer* observer) {
45 observers_.AddObserver(observer); 45 observers_.AddObserver(observer);
46 } 46 }
47 47
48 void AppLifetimeMonitor::RemoveObserver(Observer* observer) { 48 void AppLifetimeMonitor::RemoveObserver(Observer* observer) {
49 observers_.RemoveObserver(observer); 49 observers_.RemoveObserver(observer);
50 } 50 }
51 51
52 void AppLifetimeMonitor::Observe(int type, 52 void AppLifetimeMonitor::Observe(int type,
53 const content::NotificationSource& source, 53 const content::NotificationSource& source,
54 const content::NotificationDetails& details) { 54 const content::NotificationDetails& details) {
55 switch (type) { 55 switch (type) {
56 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: { 56 case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_FIRST_LOAD: {
57 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); 57 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr();
58 const Extension* extension = host->extension(); 58 const Extension* extension = host->extension();
59 if (!extension || !extension->is_platform_app()) 59 if (!extension || !extension->is_platform_app())
60 return; 60 return;
61 61
62 NotifyAppStart(extension->id()); 62 NotifyAppStart(extension->id());
63 break; 63 break;
64 } 64 }
65 65
66 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: { 66 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 void AppLifetimeMonitor::NotifyAppStop(const std::string& app_id) { 139 void AppLifetimeMonitor::NotifyAppStop(const std::string& app_id) {
140 FOR_EACH_OBSERVER(Observer, observers_, OnAppStop(profile_, app_id)); 140 FOR_EACH_OBSERVER(Observer, observers_, OnAppStop(profile_, app_id));
141 } 141 }
142 142
143 void AppLifetimeMonitor::NotifyChromeTerminating() { 143 void AppLifetimeMonitor::NotifyChromeTerminating() {
144 FOR_EACH_OBSERVER(Observer, observers_, OnChromeTerminating()); 144 FOR_EACH_OBSERVER(Observer, observers_, OnChromeTerminating());
145 } 145 }
146 146
147 } // namespace apps 147 } // namespace apps
OLDNEW
« no previous file with comments | « no previous file | apps/app_load_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698