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

Side by Side Diff: chrome/browser/extensions/api/media_galleries_private/gallery_watch_state_tracker.cc

Issue 207613002: Cleanup: Remove NOTIFICATION_EXTENSION_UNLOADED usage in MediaScanManager. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase, add error console Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // GalleryWatchStateTracker implementation. 5 // GalleryWatchStateTracker implementation.
6 6
7 #include "chrome/browser/extensions/api/media_galleries_private/gallery_watch_st ate_tracker.h" 7 #include "chrome/browser/extensions/api/media_galleries_private/gallery_watch_st ate_tracker.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 MediaGalleryPrefId gallery_id) { 184 MediaGalleryPrefId gallery_id) {
185 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 185 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
186 if (!ContainsKey(watched_extensions_map_, extension_id)) 186 if (!ContainsKey(watched_extensions_map_, extension_id))
187 return; 187 return;
188 watched_extensions_map_[extension_id].erase(gallery_id); 188 watched_extensions_map_[extension_id].erase(gallery_id);
189 if (watched_extensions_map_[extension_id].empty()) 189 if (watched_extensions_map_[extension_id].empty())
190 watched_extensions_map_.erase(extension_id); 190 watched_extensions_map_.erase(extension_id);
191 WriteToStorage(extension_id); 191 WriteToStorage(extension_id);
192 } 192 }
193 193
194 void GalleryWatchStateTracker::OnExtensionLoaded(const Extension* extension) { 194 void GalleryWatchStateTracker::OnExtensionLoaded(
195 content::BrowserContext* browser_context,
196 const Extension* extension) {
195 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 197 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
196 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); 198 StateStore* storage = ExtensionSystem::Get(profile_)->state_store();
197 if (!storage) 199 if (!storage)
198 return; 200 return;
199 storage->GetExtensionValue( 201 storage->GetExtensionValue(
200 extension->id(), 202 extension->id(),
201 kRegisteredGalleryWatchers, 203 kRegisteredGalleryWatchers,
202 base::Bind(&GalleryWatchStateTracker::ReadFromStorage, 204 base::Bind(&GalleryWatchStateTracker::ReadFromStorage,
203 AsWeakPtr(), 205 AsWeakPtr(),
204 extension->id())); 206 extension->id()));
205 } 207 }
206 208
207 void GalleryWatchStateTracker::OnExtensionUnloaded( 209 void GalleryWatchStateTracker::OnExtensionUnloaded(
210 content::BrowserContext* browser_context,
208 const Extension* extension) { 211 const Extension* extension) {
209 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
210 if (!ContainsKey(watched_extensions_map_, extension->id())) 213 if (!ContainsKey(watched_extensions_map_, extension->id()))
211 return; 214 return;
212 content::BrowserThread::PostTask( 215 content::BrowserThread::PostTask(
213 content::BrowserThread::FILE, FROM_HERE, 216 content::BrowserThread::FILE, FROM_HERE,
214 base::Bind(&GalleryWatchManager::OnExtensionUnloaded, 217 base::Bind(&GalleryWatchManager::OnExtensionUnloaded,
215 profile_, 218 profile_,
216 extension->id())); 219 extension->id()));
217 for (WatchedGalleriesMap::iterator iter = 220 for (WatchedGalleriesMap::iterator iter =
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 const std::string& extension_id, 331 const std::string& extension_id,
329 MediaGalleryPrefId gallery_id) { 332 MediaGalleryPrefId gallery_id) {
330 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 333 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
331 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) 334 if (HasGalleryWatchInfo(extension_id, gallery_id, true))
332 return false; 335 return false;
333 watched_extensions_map_[extension_id][gallery_id] = true; 336 watched_extensions_map_[extension_id][gallery_id] = true;
334 return true; 337 return true;
335 } 338 }
336 339
337 } // namespace extensions 340 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698