OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |