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

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

Issue 216513002: Replace DCHECK(BrowserThread::CurrentlyOn) with DCHECK_CURRENTLY_ON in extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 18 matching lines...) Expand all
29 namespace extensions { 29 namespace extensions {
30 30
31 namespace { 31 namespace {
32 32
33 // State store key to track the registered gallery watchers for the extensions. 33 // State store key to track the registered gallery watchers for the extensions.
34 const char kRegisteredGalleryWatchers[] = "media_gallery_watchers"; 34 const char kRegisteredGalleryWatchers[] = "media_gallery_watchers";
35 35
36 // Converts the storage |list| value to WatchedGalleryIds. 36 // Converts the storage |list| value to WatchedGalleryIds.
37 MediaGalleryPrefIdSet WatchedGalleryIdsFromValue( 37 MediaGalleryPrefIdSet WatchedGalleryIdsFromValue(
38 const base::ListValue* list) { 38 const base::ListValue* list) {
39 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 39 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
40 MediaGalleryPrefIdSet gallery_ids; 40 MediaGalleryPrefIdSet gallery_ids;
41 std::string gallery_id_str; 41 std::string gallery_id_str;
42 for (size_t i = 0; i < list->GetSize(); ++i) { 42 for (size_t i = 0; i < list->GetSize(); ++i) {
43 if (!list->GetString(i, &gallery_id_str) || gallery_id_str.empty()) 43 if (!list->GetString(i, &gallery_id_str) || gallery_id_str.empty())
44 continue; 44 continue;
45 MediaGalleryPrefId gallery_id; 45 MediaGalleryPrefId gallery_id;
46 if (base::StringToUint64(gallery_id_str, &gallery_id)) 46 if (base::StringToUint64(gallery_id_str, &gallery_id))
47 gallery_ids.insert(gallery_id); 47 gallery_ids.insert(gallery_id);
48 } 48 }
49 return gallery_ids; 49 return gallery_ids;
50 } 50 }
51 51
52 // Converts WatchedGalleryIds to a storage list value. 52 // Converts WatchedGalleryIds to a storage list value.
53 scoped_ptr<base::ListValue> WatchedGalleryIdsToValue( 53 scoped_ptr<base::ListValue> WatchedGalleryIdsToValue(
54 const MediaGalleryPrefIdSet gallery_ids) { 54 const MediaGalleryPrefIdSet gallery_ids) {
55 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 55 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
56 scoped_ptr<base::ListValue> list(new base::ListValue()); 56 scoped_ptr<base::ListValue> list(new base::ListValue());
57 for (MediaGalleryPrefIdSet::const_iterator id_iter = gallery_ids.begin(); 57 for (MediaGalleryPrefIdSet::const_iterator id_iter = gallery_ids.begin();
58 id_iter != gallery_ids.end(); ++id_iter) 58 id_iter != gallery_ids.end(); ++id_iter)
59 list->AppendString(base::Uint64ToString(*id_iter)); 59 list->AppendString(base::Uint64ToString(*id_iter));
60 return list.Pass(); 60 return list.Pass();
61 } 61 }
62 62
63 // Looks up an extension by ID. Does not include disabled extensions. 63 // Looks up an extension by ID. Does not include disabled extensions.
64 const Extension* GetExtensionById(Profile* profile, 64 const Extension* GetExtensionById(Profile* profile,
65 const std::string& extension_id) { 65 const std::string& extension_id) {
66 ExtensionService* service = profile->GetExtensionService(); 66 ExtensionService* service = profile->GetExtensionService();
67 if (!service) 67 if (!service)
68 return NULL; 68 return NULL;
69 return service->GetExtensionById(extension_id, false); 69 return service->GetExtensionById(extension_id, false);
70 } 70 }
71 71
72 } // namespace 72 } // namespace
73 73
74 GalleryWatchStateTracker::GalleryWatchStateTracker(Profile* profile) 74 GalleryWatchStateTracker::GalleryWatchStateTracker(Profile* profile)
75 : profile_(profile), 75 : profile_(profile),
76 scoped_extension_registry_observer_(this) { 76 scoped_extension_registry_observer_(this) {
77 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 77 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
78 DCHECK(profile_); 78 DCHECK(profile_);
79 scoped_extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); 79 scoped_extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
80 MediaGalleriesPreferences* preferences = 80 MediaGalleriesPreferences* preferences =
81 g_browser_process->media_file_system_registry()->GetPreferences(profile); 81 g_browser_process->media_file_system_registry()->GetPreferences(profile);
82 preferences->AddGalleryChangeObserver(this); 82 preferences->AddGalleryChangeObserver(this);
83 } 83 }
84 84
85 GalleryWatchStateTracker::~GalleryWatchStateTracker() { 85 GalleryWatchStateTracker::~GalleryWatchStateTracker() {
86 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 86 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
87 MediaGalleriesPreferences* preferences = 87 MediaGalleriesPreferences* preferences =
88 g_browser_process->media_file_system_registry()->GetPreferences(profile_); 88 g_browser_process->media_file_system_registry()->GetPreferences(profile_);
89 preferences->RemoveGalleryChangeObserver(this); 89 preferences->RemoveGalleryChangeObserver(this);
90 } 90 }
91 91
92 // static 92 // static
93 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( 93 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile(
94 Profile* profile) { 94 Profile* profile) {
95 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 95 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
96 #if defined(OS_WIN) 96 #if defined(OS_WIN)
97 // Gallery watch operation is supported only on windows. 97 // Gallery watch operation is supported only on windows.
98 // Please refer to crbug.com/144491 for more details. 98 // Please refer to crbug.com/144491 for more details.
99 DCHECK(profile); 99 DCHECK(profile);
100 MediaGalleriesPrivateAPI* private_api = 100 MediaGalleriesPrivateAPI* private_api =
101 MediaGalleriesPrivateAPI::Get(profile); 101 MediaGalleriesPrivateAPI::Get(profile);
102 // In unit tests, we don't have a MediaGalleriesPrivateAPI. 102 // In unit tests, we don't have a MediaGalleriesPrivateAPI.
103 if (private_api) 103 if (private_api)
104 return private_api->GetGalleryWatchStateTracker(); 104 return private_api->GetGalleryWatchStateTracker();
105 #endif 105 #endif
106 return NULL; 106 return NULL;
107 } 107 }
108 108
109 void GalleryWatchStateTracker::OnPermissionAdded( 109 void GalleryWatchStateTracker::OnPermissionAdded(
110 MediaGalleriesPreferences* preferences, 110 MediaGalleriesPreferences* preferences,
111 const std::string& extension_id, 111 const std::string& extension_id,
112 MediaGalleryPrefId gallery_id) { 112 MediaGalleryPrefId gallery_id) {
113 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 113 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
114 // Granted gallery permission. 114 // Granted gallery permission.
115 if (HasGalleryWatchInfo(extension_id, gallery_id, false)) 115 if (HasGalleryWatchInfo(extension_id, gallery_id, false))
116 SetupGalleryWatch(extension_id, gallery_id, preferences); 116 SetupGalleryWatch(extension_id, gallery_id, preferences);
117 } 117 }
118 118
119 void GalleryWatchStateTracker::OnPermissionRemoved( 119 void GalleryWatchStateTracker::OnPermissionRemoved(
120 MediaGalleriesPreferences* preferences, 120 MediaGalleriesPreferences* preferences,
121 const std::string& extension_id, 121 const std::string& extension_id,
122 MediaGalleryPrefId gallery_id) { 122 MediaGalleryPrefId gallery_id) {
123 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 123 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
124 // Revoked gallery permission. 124 // Revoked gallery permission.
125 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) 125 if (HasGalleryWatchInfo(extension_id, gallery_id, true))
126 RemoveGalleryWatch(extension_id, gallery_id, preferences); 126 RemoveGalleryWatch(extension_id, gallery_id, preferences);
127 } 127 }
128 128
129 void GalleryWatchStateTracker::OnGalleryRemoved(MediaGalleriesPreferences* pref, 129 void GalleryWatchStateTracker::OnGalleryRemoved(MediaGalleriesPreferences* pref,
130 MediaGalleryPrefId gallery_id) { 130 MediaGalleryPrefId gallery_id) {
131 for (WatchedExtensionsMap::const_iterator it = 131 for (WatchedExtensionsMap::const_iterator it =
132 watched_extensions_map_.begin(); 132 watched_extensions_map_.begin();
133 it != watched_extensions_map_.end(); 133 it != watched_extensions_map_.end();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 for (WatchedGalleriesMap::const_iterator gallery_id_iter = galleries.begin(); 165 for (WatchedGalleriesMap::const_iterator gallery_id_iter = galleries.begin();
166 gallery_id_iter != galleries.end(); ++gallery_id_iter) 166 gallery_id_iter != galleries.end(); ++gallery_id_iter)
167 RemoveGalleryWatch(extension_id, gallery_id_iter->second, preferences); 167 RemoveGalleryWatch(extension_id, gallery_id_iter->second, preferences);
168 watched_extensions_map_.erase(extension_id_iter); 168 watched_extensions_map_.erase(extension_id_iter);
169 WriteToStorage(extension_id); 169 WriteToStorage(extension_id);
170 } 170 }
171 171
172 void GalleryWatchStateTracker::OnGalleryWatchAdded( 172 void GalleryWatchStateTracker::OnGalleryWatchAdded(
173 const std::string& extension_id, 173 const std::string& extension_id,
174 MediaGalleryPrefId gallery_id) { 174 MediaGalleryPrefId gallery_id) {
175 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
176 bool update_storage = 176 bool update_storage =
177 AddWatchedGalleryIdInfoForExtension(extension_id, gallery_id); 177 AddWatchedGalleryIdInfoForExtension(extension_id, gallery_id);
178 if (update_storage) 178 if (update_storage)
179 WriteToStorage(extension_id); 179 WriteToStorage(extension_id);
180 } 180 }
181 181
182 void GalleryWatchStateTracker::OnGalleryWatchRemoved( 182 void GalleryWatchStateTracker::OnGalleryWatchRemoved(
183 const std::string& extension_id, 183 const std::string& extension_id,
184 MediaGalleryPrefId gallery_id) { 184 MediaGalleryPrefId gallery_id) {
185 DCHECK(content::BrowserThread::CurrentlyOn(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(const Extension* extension) {
195 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 195 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
196 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); 196 StateStore* storage = ExtensionSystem::Get(profile_)->state_store();
197 if (!storage) 197 if (!storage)
198 return; 198 return;
199 storage->GetExtensionValue( 199 storage->GetExtensionValue(
200 extension->id(), 200 extension->id(),
201 kRegisteredGalleryWatchers, 201 kRegisteredGalleryWatchers,
202 base::Bind(&GalleryWatchStateTracker::ReadFromStorage, 202 base::Bind(&GalleryWatchStateTracker::ReadFromStorage,
203 AsWeakPtr(), 203 AsWeakPtr(),
204 extension->id())); 204 extension->id()));
205 } 205 }
206 206
207 void GalleryWatchStateTracker::OnExtensionUnloaded( 207 void GalleryWatchStateTracker::OnExtensionUnloaded(
208 const Extension* extension) { 208 const Extension* extension) {
209 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 209 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
210 if (!ContainsKey(watched_extensions_map_, extension->id())) 210 if (!ContainsKey(watched_extensions_map_, extension->id()))
211 return; 211 return;
212 content::BrowserThread::PostTask( 212 content::BrowserThread::PostTask(
213 content::BrowserThread::FILE, FROM_HERE, 213 content::BrowserThread::FILE, FROM_HERE,
214 base::Bind(&GalleryWatchManager::OnExtensionUnloaded, 214 base::Bind(&GalleryWatchManager::OnExtensionUnloaded,
215 profile_, 215 profile_,
216 extension->id())); 216 extension->id()));
217 for (WatchedGalleriesMap::iterator iter = 217 for (WatchedGalleriesMap::iterator iter =
218 watched_extensions_map_[extension->id()].begin(); 218 watched_extensions_map_[extension->id()].begin();
219 iter != watched_extensions_map_[extension->id()].end(); ++iter) { 219 iter != watched_extensions_map_[extension->id()].end(); ++iter) {
220 iter->second = false; 220 iter->second = false;
221 } 221 }
222 } 222 }
223 223
224 void GalleryWatchStateTracker::WriteToStorage(const std::string& extension_id) { 224 void GalleryWatchStateTracker::WriteToStorage(const std::string& extension_id) {
225 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 225 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
226 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); 226 StateStore* storage = ExtensionSystem::Get(profile_)->state_store();
227 if (!storage) 227 if (!storage)
228 return; 228 return;
229 MediaGalleryPrefIdSet gallery_ids = 229 MediaGalleryPrefIdSet gallery_ids =
230 GetAllWatchedGalleryIDsForExtension(extension_id); 230 GetAllWatchedGalleryIDsForExtension(extension_id);
231 storage->SetExtensionValue( 231 storage->SetExtensionValue(
232 extension_id, 232 extension_id,
233 kRegisteredGalleryWatchers, 233 kRegisteredGalleryWatchers,
234 WatchedGalleryIdsToValue(gallery_ids).PassAs<base::Value>()); 234 WatchedGalleryIdsToValue(gallery_ids).PassAs<base::Value>());
235 } 235 }
236 236
237 void GalleryWatchStateTracker::ReadFromStorage( 237 void GalleryWatchStateTracker::ReadFromStorage(
238 const std::string& extension_id, 238 const std::string& extension_id,
239 scoped_ptr<base::Value> value) { 239 scoped_ptr<base::Value> value) {
240 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 240 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
241 MediaGalleriesPreferences* preferences = 241 MediaGalleriesPreferences* preferences =
242 g_browser_process->media_file_system_registry()->GetPreferences(profile_); 242 g_browser_process->media_file_system_registry()->GetPreferences(profile_);
243 base::ListValue* list = NULL; 243 base::ListValue* list = NULL;
244 if (!value.get() || !value->GetAsList(&list)) 244 if (!value.get() || !value->GetAsList(&list))
245 return; 245 return;
246 MediaGalleryPrefIdSet gallery_ids = WatchedGalleryIdsFromValue(list); 246 MediaGalleryPrefIdSet gallery_ids = WatchedGalleryIdsFromValue(list);
247 if (gallery_ids.empty()) 247 if (gallery_ids.empty())
248 return; 248 return;
249 249
250 for (MediaGalleryPrefIdSet::const_iterator id_iter = gallery_ids.begin(); 250 for (MediaGalleryPrefIdSet::const_iterator id_iter = gallery_ids.begin();
251 id_iter != gallery_ids.end(); ++id_iter) { 251 id_iter != gallery_ids.end(); ++id_iter) {
252 watched_extensions_map_[extension_id][*id_iter] = false; 252 watched_extensions_map_[extension_id][*id_iter] = false;
253 SetupGalleryWatch(extension_id, *id_iter, preferences); 253 SetupGalleryWatch(extension_id, *id_iter, preferences);
254 } 254 }
255 } 255 }
256 256
257 void GalleryWatchStateTracker::SetupGalleryWatch( 257 void GalleryWatchStateTracker::SetupGalleryWatch(
258 const std::string& extension_id, 258 const std::string& extension_id,
259 MediaGalleryPrefId gallery_id, 259 MediaGalleryPrefId gallery_id,
260 MediaGalleriesPreferences* preferences) { 260 MediaGalleriesPreferences* preferences) {
261 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 261 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
262 const Extension* extension = GetExtensionById(profile_, extension_id); 262 const Extension* extension = GetExtensionById(profile_, extension_id);
263 DCHECK(extension); 263 DCHECK(extension);
264 base::FilePath gallery_file_path(preferences->LookUpGalleryPathForExtension( 264 base::FilePath gallery_file_path(preferences->LookUpGalleryPathForExtension(
265 gallery_id, extension, false)); 265 gallery_id, extension, false));
266 if (gallery_file_path.empty()) 266 if (gallery_file_path.empty())
267 return; 267 return;
268 MediaGalleriesPrivateEventRouter* router = 268 MediaGalleriesPrivateEventRouter* router =
269 MediaGalleriesPrivateAPI::Get(profile_)->GetEventRouter(); 269 MediaGalleriesPrivateAPI::Get(profile_)->GetEventRouter();
270 DCHECK(router); 270 DCHECK(router);
271 content::BrowserThread::PostTaskAndReplyWithResult( 271 content::BrowserThread::PostTaskAndReplyWithResult(
272 content::BrowserThread::FILE, 272 content::BrowserThread::FILE,
273 FROM_HERE, 273 FROM_HERE,
274 base::Bind(&GalleryWatchManager::SetupGalleryWatch, 274 base::Bind(&GalleryWatchManager::SetupGalleryWatch,
275 profile_, 275 profile_,
276 gallery_id, 276 gallery_id,
277 gallery_file_path, 277 gallery_file_path,
278 extension_id, 278 extension_id,
279 router->AsWeakPtr()), 279 router->AsWeakPtr()),
280 base::Bind(&GalleryWatchStateTracker::HandleSetupGalleryWatchResponse, 280 base::Bind(&GalleryWatchStateTracker::HandleSetupGalleryWatchResponse,
281 AsWeakPtr(), 281 AsWeakPtr(),
282 extension_id, 282 extension_id,
283 gallery_id)); 283 gallery_id));
284 } 284 }
285 285
286 void GalleryWatchStateTracker::RemoveGalleryWatch( 286 void GalleryWatchStateTracker::RemoveGalleryWatch(
287 const std::string& extension_id, 287 const std::string& extension_id,
288 MediaGalleryPrefId gallery_id, 288 MediaGalleryPrefId gallery_id,
289 MediaGalleriesPreferences* preferences) { 289 MediaGalleriesPreferences* preferences) {
290 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 290 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
291 const Extension* extension = GetExtensionById(profile_, extension_id); 291 const Extension* extension = GetExtensionById(profile_, extension_id);
292 DCHECK(extension); 292 DCHECK(extension);
293 base::FilePath gallery_file_path(preferences->LookUpGalleryPathForExtension( 293 base::FilePath gallery_file_path(preferences->LookUpGalleryPathForExtension(
294 gallery_id, extension, true)); 294 gallery_id, extension, true));
295 if (gallery_file_path.empty()) 295 if (gallery_file_path.empty())
296 return; 296 return;
297 content::BrowserThread::PostTask( 297 content::BrowserThread::PostTask(
298 content::BrowserThread::FILE, FROM_HERE, 298 content::BrowserThread::FILE, FROM_HERE,
299 base::Bind(&GalleryWatchManager::RemoveGalleryWatch, 299 base::Bind(&GalleryWatchManager::RemoveGalleryWatch,
300 profile_, 300 profile_,
301 gallery_file_path, 301 gallery_file_path,
302 extension_id)); 302 extension_id));
303 watched_extensions_map_[extension_id][gallery_id] = false; 303 watched_extensions_map_[extension_id][gallery_id] = false;
304 } 304 }
305 305
306 bool GalleryWatchStateTracker::HasGalleryWatchInfo( 306 bool GalleryWatchStateTracker::HasGalleryWatchInfo(
307 const std::string& extension_id, 307 const std::string& extension_id,
308 MediaGalleryPrefId gallery_id, 308 MediaGalleryPrefId gallery_id,
309 bool has_active_watcher) { 309 bool has_active_watcher) {
310 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 310 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
311 return (ContainsKey(watched_extensions_map_, extension_id) && 311 return (ContainsKey(watched_extensions_map_, extension_id) &&
312 ContainsKey(watched_extensions_map_[extension_id], gallery_id) && 312 ContainsKey(watched_extensions_map_[extension_id], gallery_id) &&
313 watched_extensions_map_[extension_id][gallery_id] == 313 watched_extensions_map_[extension_id][gallery_id] ==
314 has_active_watcher); 314 has_active_watcher);
315 } 315 }
316 316
317 void GalleryWatchStateTracker::HandleSetupGalleryWatchResponse( 317 void GalleryWatchStateTracker::HandleSetupGalleryWatchResponse(
318 const std::string& extension_id, 318 const std::string& extension_id,
319 MediaGalleryPrefId gallery_id, 319 MediaGalleryPrefId gallery_id,
320 bool success) { 320 bool success) {
321 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 321 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
322 if (!success) 322 if (!success)
323 return; // Failed to setup the gallery watch for the given extension. 323 return; // Failed to setup the gallery watch for the given extension.
324 AddWatchedGalleryIdInfoForExtension(extension_id, gallery_id); 324 AddWatchedGalleryIdInfoForExtension(extension_id, gallery_id);
325 } 325 }
326 326
327 bool GalleryWatchStateTracker::AddWatchedGalleryIdInfoForExtension( 327 bool GalleryWatchStateTracker::AddWatchedGalleryIdInfoForExtension(
328 const std::string& extension_id, 328 const std::string& extension_id,
329 MediaGalleryPrefId gallery_id) { 329 MediaGalleryPrefId gallery_id) {
330 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 330 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
331 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) 331 if (HasGalleryWatchInfo(extension_id, gallery_id, true))
332 return false; 332 return false;
333 watched_extensions_map_[extension_id][gallery_id] = true; 333 watched_extensions_map_[extension_id][gallery_id] = true;
334 return true; 334 return true;
335 } 335 }
336 336
337 } // namespace extensions 337 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698