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

Side by Side Diff: chrome/browser/apps/ephemeral_app_service.cc

Issue 298253002: cleanup: Remove NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED from c/b/apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unwanted DCHECK Created 6 years, 7 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/apps/ephemeral_app_service.h ('k') | chrome/browser/apps/shortcut_manager.h » ('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 "chrome/browser/apps/ephemeral_app_service.h" 5 #include "chrome/browser/apps/ephemeral_app_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/apps/ephemeral_app_service_factory.h" 8 #include "chrome/browser/apps/ephemeral_app_service_factory.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/extensions/data_deleter.h" 10 #include "chrome/browser/extensions/data_deleter.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const int EphemeralAppService::kMaxEphemeralAppsCount = 30; 55 const int EphemeralAppService::kMaxEphemeralAppsCount = 30;
56 const int EphemeralAppService::kDataInactiveThreshold = 90; 56 const int EphemeralAppService::kDataInactiveThreshold = 90;
57 57
58 // static 58 // static
59 EphemeralAppService* EphemeralAppService::Get(Profile* profile) { 59 EphemeralAppService* EphemeralAppService::Get(Profile* profile) {
60 return EphemeralAppServiceFactory::GetForProfile(profile); 60 return EphemeralAppServiceFactory::GetForProfile(profile);
61 } 61 }
62 62
63 EphemeralAppService::EphemeralAppService(Profile* profile) 63 EphemeralAppService::EphemeralAppService(Profile* profile)
64 : profile_(profile), 64 : profile_(profile),
65 extension_registry_observer_(this),
65 ephemeral_app_count_(-1) { 66 ephemeral_app_count_(-1) {
66 if (!CommandLine::ForCurrentProcess()->HasSwitch( 67 if (!CommandLine::ForCurrentProcess()->HasSwitch(
67 switches::kEnableEphemeralApps)) 68 switches::kEnableEphemeralApps))
68 return; 69 return;
69 70
70 registrar_.Add(this, 71 extension_registry_observer_.Add(
71 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED, 72 extensions::ExtensionRegistry::Get(profile_));
72 content::Source<Profile>(profile_));
73 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
74 content::Source<Profile>(profile_));
75 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, 73 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
76 content::Source<Profile>(profile_)); 74 content::Source<Profile>(profile_));
77 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, 75 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
78 content::Source<Profile>(profile_)); 76 content::Source<Profile>(profile_));
79 } 77 }
80 78
81 EphemeralAppService::~EphemeralAppService() { 79 EphemeralAppService::~EphemeralAppService() {
82 } 80 }
83 81
84 void EphemeralAppService::Observe( 82 void EphemeralAppService::Observe(
85 int type, 83 int type,
86 const content::NotificationSource& source, 84 const content::NotificationSource& source,
87 const content::NotificationDetails& details) { 85 const content::NotificationDetails& details) {
88 switch (type) { 86 switch (type) {
89 case chrome::NOTIFICATION_EXTENSIONS_READY: { 87 case chrome::NOTIFICATION_EXTENSIONS_READY: {
90 Init(); 88 Init();
91 break; 89 break;
92 } 90 }
93 case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: {
94 const Extension* extension =
95 content::Details<const InstalledExtensionInfo>(details)->extension;
96 DCHECK(extension);
97 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) {
98 ++ephemeral_app_count_;
99 if (ephemeral_app_count_ >= kGarbageCollectAppsTriggerCount)
100 TriggerGarbageCollect(
101 base::TimeDelta::FromSeconds(kGarbageCollectAppsInstallDelay));
102 }
103 break;
104 }
105 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
106 const Extension* extension =
107 content::Details<const Extension>(details).ptr();
108 DCHECK(extension);
109 if (extensions::util::IsEphemeralApp(extension->id(), profile_))
110 --ephemeral_app_count_;
111 break;
112 }
113 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 91 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
114 // Ideally we need to know when the extension system is shutting down. 92 // Ideally we need to know when the extension system is shutting down.
115 garbage_collect_apps_timer_.Stop(); 93 garbage_collect_apps_timer_.Stop();
116 break; 94 break;
117 } 95 }
118 default: 96 default:
119 NOTREACHED(); 97 NOTREACHED();
120 } 98 }
121 } 99 }
122 100
101 void EphemeralAppService::OnExtensionWillBeInstalled(
102 content::BrowserContext* browser_context,
103 const extensions::Extension* extension,
104 bool is_update,
105 const std::string& old_name) {
106 if (extensions::util::IsEphemeralApp(extension->id(), profile_)) {
107 ++ephemeral_app_count_;
108 if (ephemeral_app_count_ >= kGarbageCollectAppsTriggerCount)
109 TriggerGarbageCollect(
110 base::TimeDelta::FromSeconds(kGarbageCollectAppsInstallDelay));
111 }
112 }
113
114 void EphemeralAppService::OnExtensionUninstalled(
115 content::BrowserContext* browser_context,
116 const extensions::Extension* extension) {
117 if (extensions::util::IsEphemeralApp(extension->id(), profile_))
118 --ephemeral_app_count_;
119 }
120
123 void EphemeralAppService::Init() { 121 void EphemeralAppService::Init() {
124 InitEphemeralAppCount(); 122 InitEphemeralAppCount();
125 TriggerGarbageCollect( 123 TriggerGarbageCollect(
126 base::TimeDelta::FromSeconds(kGarbageCollectAppsStartupDelay)); 124 base::TimeDelta::FromSeconds(kGarbageCollectAppsStartupDelay));
127 125
128 garbage_collect_data_timer_.Start( 126 garbage_collect_data_timer_.Start(
129 FROM_HERE, 127 FROM_HERE,
130 base::TimeDelta::FromSeconds(kGarbageCollectDataStartupDelay), 128 base::TimeDelta::FromSeconds(kGarbageCollectDataStartupDelay),
131 this, 129 this,
132 &EphemeralAppService::GarbageCollectData); 130 &EphemeralAppService::GarbageCollectData);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 info->extension_id, 278 info->extension_id,
281 &error)); 279 &error));
282 280
283 if (extension.get()) 281 if (extension.get())
284 extensions::DataDeleter::StartDeleting(profile_, extension.get()); 282 extensions::DataDeleter::StartDeleting(profile_, extension.get());
285 } 283 }
286 284
287 prefs->RemoveEvictedEphemeralApp(info->extension_id); 285 prefs->RemoveEvictedEphemeralApp(info->extension_id);
288 } 286 }
289 } 287 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/ephemeral_app_service.h ('k') | chrome/browser/apps/shortcut_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698