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

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

Issue 23727009: Cleanup: Remove chrome namespace for storage monitor and media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 7 years, 3 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 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
30 30
31 namespace extensions { 31 namespace extensions {
32 32
33 namespace { 33 namespace {
34 34
35 // State store key to track the registered gallery watchers for the extensions. 35 // State store key to track the registered gallery watchers for the extensions.
36 const char kRegisteredGalleryWatchers[] = "media_gallery_watchers"; 36 const char kRegisteredGalleryWatchers[] = "media_gallery_watchers";
37 37
38 // Converts the storage |list| value to WatchedGalleryIds. 38 // Converts the storage |list| value to WatchedGalleryIds.
39 chrome::MediaGalleryPrefIdSet WatchedGalleryIdsFromValue( 39 MediaGalleryPrefIdSet WatchedGalleryIdsFromValue(
40 const base::ListValue* list) { 40 const base::ListValue* list) {
41 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 41 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
42 chrome::MediaGalleryPrefIdSet gallery_ids; 42 MediaGalleryPrefIdSet gallery_ids;
43 std::string gallery_id_str; 43 std::string gallery_id_str;
44 for (size_t i = 0; i < list->GetSize(); ++i) { 44 for (size_t i = 0; i < list->GetSize(); ++i) {
45 if (!list->GetString(i, &gallery_id_str) || gallery_id_str.empty()) 45 if (!list->GetString(i, &gallery_id_str) || gallery_id_str.empty())
46 continue; 46 continue;
47 chrome::MediaGalleryPrefId gallery_id; 47 MediaGalleryPrefId gallery_id;
48 if (base::StringToUint64(gallery_id_str, &gallery_id)) 48 if (base::StringToUint64(gallery_id_str, &gallery_id))
49 gallery_ids.insert(gallery_id); 49 gallery_ids.insert(gallery_id);
50 } 50 }
51 return gallery_ids; 51 return gallery_ids;
52 } 52 }
53 53
54 // Converts WatchedGalleryIds to a storage list value. 54 // Converts WatchedGalleryIds to a storage list value.
55 scoped_ptr<base::ListValue> WatchedGalleryIdsToValue( 55 scoped_ptr<base::ListValue> WatchedGalleryIdsToValue(
56 const chrome::MediaGalleryPrefIdSet gallery_ids) { 56 const MediaGalleryPrefIdSet gallery_ids) {
57 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 57 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
58 scoped_ptr<base::ListValue> list(new base::ListValue()); 58 scoped_ptr<base::ListValue> list(new base::ListValue());
59 for (chrome::MediaGalleryPrefIdSet::const_iterator id_iter = 59 for (MediaGalleryPrefIdSet::const_iterator id_iter = gallery_ids.begin();
60 gallery_ids.begin();
61 id_iter != gallery_ids.end(); ++id_iter) 60 id_iter != gallery_ids.end(); ++id_iter)
62 list->AppendString(base::Uint64ToString(*id_iter)); 61 list->AppendString(base::Uint64ToString(*id_iter));
63 return list.Pass(); 62 return list.Pass();
64 } 63 }
65 64
66 // Looks up an extension by ID. Does not include disabled extensions. 65 // Looks up an extension by ID. Does not include disabled extensions.
67 const Extension* GetExtensionById(Profile* profile, 66 const Extension* GetExtensionById(Profile* profile,
68 const std::string& extension_id) { 67 const std::string& extension_id) {
69 ExtensionService* service = profile->GetExtensionService(); 68 ExtensionService* service = profile->GetExtensionService();
70 if (!service) 69 if (!service)
71 return NULL; 70 return NULL;
72 return service->GetExtensionById(extension_id, false); 71 return service->GetExtensionById(extension_id, false);
73 } 72 }
74 73
75 } // namespace 74 } // namespace
76 75
77 GalleryWatchStateTracker::GalleryWatchStateTracker(Profile* profile) 76 GalleryWatchStateTracker::GalleryWatchStateTracker(Profile* profile)
78 : profile_(profile) { 77 : profile_(profile) {
79 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 78 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
80 DCHECK(profile_); 79 DCHECK(profile_);
81 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 80 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
82 content::Source<Profile>(profile_)); 81 content::Source<Profile>(profile_));
83 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 82 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
84 content::Source<Profile>(profile_)); 83 content::Source<Profile>(profile_));
85 chrome::MediaGalleriesPreferences* preferences = 84 MediaGalleriesPreferences* preferences =
86 g_browser_process->media_file_system_registry()->GetPreferences( 85 g_browser_process->media_file_system_registry()->GetPreferences(
87 profile); 86 profile);
88 preferences->AddGalleryChangeObserver(this); 87 preferences->AddGalleryChangeObserver(this);
89 } 88 }
90 89
91 GalleryWatchStateTracker::~GalleryWatchStateTracker() { 90 GalleryWatchStateTracker::~GalleryWatchStateTracker() {
92 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 91 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
93 chrome::MediaGalleriesPreferences* preferences = 92 MediaGalleriesPreferences* preferences =
94 g_browser_process->media_file_system_registry()->GetPreferences( 93 g_browser_process->media_file_system_registry()->GetPreferences(
95 profile_); 94 profile_);
96 preferences->RemoveGalleryChangeObserver(this); 95 preferences->RemoveGalleryChangeObserver(this);
97 } 96 }
98 97
99 // static 98 // static
100 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile( 99 GalleryWatchStateTracker* GalleryWatchStateTracker::GetForProfile(
101 Profile* profile) { 100 Profile* profile) {
102 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 101 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
103 #if defined(OS_WIN) 102 #if defined(OS_WIN)
104 // Gallery watch operation is supported only on windows. 103 // Gallery watch operation is supported only on windows.
105 // Please refer to crbug.com/144491 for more details. 104 // Please refer to crbug.com/144491 for more details.
106 DCHECK(profile); 105 DCHECK(profile);
107 MediaGalleriesPrivateAPI* private_api = 106 MediaGalleriesPrivateAPI* private_api =
108 MediaGalleriesPrivateAPI::Get(profile); 107 MediaGalleriesPrivateAPI::Get(profile);
109 if (!private_api) 108 if (!private_api)
110 return NULL; // In unit tests, we don't have a MediaGalleriesPrivateAPI. 109 return NULL; // In unit tests, we don't have a MediaGalleriesPrivateAPI.
111 return private_api->GetGalleryWatchStateTracker(); 110 return private_api->GetGalleryWatchStateTracker();
112 #endif 111 #endif
113 return NULL; 112 return NULL;
114 } 113 }
115 114
116 void GalleryWatchStateTracker::OnGalleryChanged( 115 void GalleryWatchStateTracker::OnGalleryChanged(
117 chrome::MediaGalleriesPreferences* preferences, 116 MediaGalleriesPreferences* preferences,
118 const std::string& extension_id, 117 const std::string& extension_id,
119 chrome::MediaGalleryPrefId gallery_id, 118 MediaGalleryPrefId gallery_id,
120 bool has_permission) { 119 bool has_permission) {
121 if (extension_id.empty()) 120 if (extension_id.empty())
122 return; 121 return;
123 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 122 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
124 // Granted gallery permission. 123 // Granted gallery permission.
125 if (has_permission && HasGalleryWatchInfo(extension_id, gallery_id, false)) { 124 if (has_permission && HasGalleryWatchInfo(extension_id, gallery_id, false)) {
126 SetupGalleryWatch(extension_id, gallery_id, preferences); 125 SetupGalleryWatch(extension_id, gallery_id, preferences);
127 return; 126 return;
128 } 127 }
129 128
130 // Revoked gallery permission. 129 // Revoked gallery permission.
131 if (!has_permission && HasGalleryWatchInfo(extension_id, gallery_id, true)) 130 if (!has_permission && HasGalleryWatchInfo(extension_id, gallery_id, true))
132 RemoveGalleryWatch(extension_id, gallery_id, preferences); 131 RemoveGalleryWatch(extension_id, gallery_id, preferences);
133 } 132 }
134 133
135 chrome::MediaGalleryPrefIdSet 134 MediaGalleryPrefIdSet
136 GalleryWatchStateTracker::GetAllWatchedGalleryIDsForExtension( 135 GalleryWatchStateTracker::GetAllWatchedGalleryIDsForExtension(
137 const std::string& extension_id) const { 136 const std::string& extension_id) const {
138 chrome::MediaGalleryPrefIdSet gallery_ids; 137 MediaGalleryPrefIdSet gallery_ids;
139 WatchedExtensionsMap::const_iterator extension_id_iter = 138 WatchedExtensionsMap::const_iterator extension_id_iter =
140 watched_extensions_map_.find(extension_id); 139 watched_extensions_map_.find(extension_id);
141 if (extension_id_iter != watched_extensions_map_.end()) { 140 if (extension_id_iter != watched_extensions_map_.end()) {
142 for (WatchedGalleriesMap::const_iterator gallery_id_iter = 141 for (WatchedGalleriesMap::const_iterator gallery_id_iter =
143 extension_id_iter->second.begin(); 142 extension_id_iter->second.begin();
144 gallery_id_iter != extension_id_iter->second.end(); 143 gallery_id_iter != extension_id_iter->second.end();
145 ++gallery_id_iter) { 144 ++gallery_id_iter) {
146 gallery_ids.insert(gallery_id_iter->first); 145 gallery_ids.insert(gallery_id_iter->first);
147 } 146 }
148 } 147 }
149 return gallery_ids; 148 return gallery_ids;
150 } 149 }
151 150
152 void GalleryWatchStateTracker::RemoveAllGalleryWatchersForExtension( 151 void GalleryWatchStateTracker::RemoveAllGalleryWatchersForExtension(
153 const std::string& extension_id, 152 const std::string& extension_id,
154 chrome::MediaGalleriesPreferences* preferences) { 153 MediaGalleriesPreferences* preferences) {
155 WatchedExtensionsMap::iterator extension_id_iter = 154 WatchedExtensionsMap::iterator extension_id_iter =
156 watched_extensions_map_.find(extension_id); 155 watched_extensions_map_.find(extension_id);
157 if (extension_id_iter == watched_extensions_map_.end()) 156 if (extension_id_iter == watched_extensions_map_.end())
158 return; 157 return;
159 const WatchedGalleriesMap& galleries = extension_id_iter->second; 158 const WatchedGalleriesMap& galleries = extension_id_iter->second;
160 for (WatchedGalleriesMap::const_iterator gallery_id_iter = galleries.begin(); 159 for (WatchedGalleriesMap::const_iterator gallery_id_iter = galleries.begin();
161 gallery_id_iter != galleries.end(); ++gallery_id_iter) 160 gallery_id_iter != galleries.end(); ++gallery_id_iter)
162 RemoveGalleryWatch(extension_id, gallery_id_iter->second, preferences); 161 RemoveGalleryWatch(extension_id, gallery_id_iter->second, preferences);
163 watched_extensions_map_.erase(extension_id_iter); 162 watched_extensions_map_.erase(extension_id_iter);
164 WriteToStorage(extension_id); 163 WriteToStorage(extension_id);
165 } 164 }
166 165
167 void GalleryWatchStateTracker::OnGalleryWatchAdded( 166 void GalleryWatchStateTracker::OnGalleryWatchAdded(
168 const std::string& extension_id, 167 const std::string& extension_id,
169 chrome::MediaGalleryPrefId gallery_id) { 168 MediaGalleryPrefId gallery_id) {
170 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 169 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
171 bool update_storage = 170 bool update_storage =
172 AddWatchedGalleryIdInfoForExtension(extension_id, gallery_id); 171 AddWatchedGalleryIdInfoForExtension(extension_id, gallery_id);
173 if (update_storage) 172 if (update_storage)
174 WriteToStorage(extension_id); 173 WriteToStorage(extension_id);
175 } 174 }
176 175
177 void GalleryWatchStateTracker::OnGalleryWatchRemoved( 176 void GalleryWatchStateTracker::OnGalleryWatchRemoved(
178 const std::string& extension_id, 177 const std::string& extension_id,
179 chrome::MediaGalleryPrefId gallery_id) { 178 MediaGalleryPrefId gallery_id) {
180 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 179 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
181 if (!ContainsKey(watched_extensions_map_, extension_id)) 180 if (!ContainsKey(watched_extensions_map_, extension_id))
182 return; 181 return;
183 watched_extensions_map_[extension_id].erase(gallery_id); 182 watched_extensions_map_[extension_id].erase(gallery_id);
184 if (watched_extensions_map_[extension_id].empty()) 183 if (watched_extensions_map_[extension_id].empty())
185 watched_extensions_map_.erase(extension_id); 184 watched_extensions_map_.erase(extension_id);
186 WriteToStorage(extension_id); 185 WriteToStorage(extension_id);
187 } 186 }
188 187
189 void GalleryWatchStateTracker::Observe( 188 void GalleryWatchStateTracker::Observe(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 default: 227 default:
229 NOTREACHED(); 228 NOTREACHED();
230 } 229 }
231 } 230 }
232 231
233 void GalleryWatchStateTracker::WriteToStorage(const std::string& extension_id) { 232 void GalleryWatchStateTracker::WriteToStorage(const std::string& extension_id) {
234 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 233 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
235 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); 234 StateStore* storage = ExtensionSystem::Get(profile_)->state_store();
236 if (!storage) 235 if (!storage)
237 return; 236 return;
238 chrome::MediaGalleryPrefIdSet gallery_ids = 237 MediaGalleryPrefIdSet gallery_ids =
239 GetAllWatchedGalleryIDsForExtension(extension_id); 238 GetAllWatchedGalleryIDsForExtension(extension_id);
240 storage->SetExtensionValue( 239 storage->SetExtensionValue(
241 extension_id, 240 extension_id,
242 kRegisteredGalleryWatchers, 241 kRegisteredGalleryWatchers,
243 WatchedGalleryIdsToValue(gallery_ids).PassAs<base::Value>()); 242 WatchedGalleryIdsToValue(gallery_ids).PassAs<base::Value>());
244 } 243 }
245 244
246 void GalleryWatchStateTracker::ReadFromStorage( 245 void GalleryWatchStateTracker::ReadFromStorage(
247 const std::string& extension_id, 246 const std::string& extension_id,
248 scoped_ptr<base::Value> value) { 247 scoped_ptr<base::Value> value) {
249 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 248 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
250 chrome::MediaGalleriesPreferences* preferences = 249 MediaGalleriesPreferences* preferences =
251 g_browser_process->media_file_system_registry()->GetPreferences(profile_); 250 g_browser_process->media_file_system_registry()->GetPreferences(profile_);
252 base::ListValue* list = NULL; 251 base::ListValue* list = NULL;
253 if (!value.get() || !value->GetAsList(&list)) 252 if (!value.get() || !value->GetAsList(&list))
254 return; 253 return;
255 chrome::MediaGalleryPrefIdSet gallery_ids = WatchedGalleryIdsFromValue(list); 254 MediaGalleryPrefIdSet gallery_ids = WatchedGalleryIdsFromValue(list);
256 if (gallery_ids.empty()) 255 if (gallery_ids.empty())
257 return; 256 return;
258 257
259 for (chrome::MediaGalleryPrefIdSet::const_iterator id_iter = 258 for (MediaGalleryPrefIdSet::const_iterator id_iter = gallery_ids.begin();
260 gallery_ids.begin();
261 id_iter != gallery_ids.end(); ++id_iter) { 259 id_iter != gallery_ids.end(); ++id_iter) {
262 watched_extensions_map_[extension_id][*id_iter] = false; 260 watched_extensions_map_[extension_id][*id_iter] = false;
263 SetupGalleryWatch(extension_id, *id_iter, preferences); 261 SetupGalleryWatch(extension_id, *id_iter, preferences);
264 } 262 }
265 } 263 }
266 264
267 void GalleryWatchStateTracker::SetupGalleryWatch( 265 void GalleryWatchStateTracker::SetupGalleryWatch(
268 const std::string& extension_id, 266 const std::string& extension_id,
269 chrome::MediaGalleryPrefId gallery_id, 267 MediaGalleryPrefId gallery_id,
270 chrome::MediaGalleriesPreferences* preferences) { 268 MediaGalleriesPreferences* preferences) {
271 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 269 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
272 const Extension* extension = GetExtensionById(profile_, extension_id); 270 const Extension* extension = GetExtensionById(profile_, extension_id);
273 DCHECK(extension); 271 DCHECK(extension);
274 base::FilePath gallery_file_path(preferences->LookUpGalleryPathForExtension( 272 base::FilePath gallery_file_path(preferences->LookUpGalleryPathForExtension(
275 gallery_id, extension, false)); 273 gallery_id, extension, false));
276 if (gallery_file_path.empty()) 274 if (gallery_file_path.empty())
277 return; 275 return;
278 MediaGalleriesPrivateEventRouter* router = 276 MediaGalleriesPrivateEventRouter* router =
279 MediaGalleriesPrivateAPI::Get(profile_)->GetEventRouter(); 277 MediaGalleriesPrivateAPI::Get(profile_)->GetEventRouter();
280 DCHECK(router); 278 DCHECK(router);
281 content::BrowserThread::PostTaskAndReplyWithResult( 279 content::BrowserThread::PostTaskAndReplyWithResult(
282 content::BrowserThread::FILE, 280 content::BrowserThread::FILE,
283 FROM_HERE, 281 FROM_HERE,
284 base::Bind(&GalleryWatchManager::SetupGalleryWatch, 282 base::Bind(&GalleryWatchManager::SetupGalleryWatch,
285 profile_, 283 profile_,
286 gallery_id, 284 gallery_id,
287 gallery_file_path, 285 gallery_file_path,
288 extension_id, 286 extension_id,
289 router->AsWeakPtr()), 287 router->AsWeakPtr()),
290 base::Bind(&GalleryWatchStateTracker::HandleSetupGalleryWatchResponse, 288 base::Bind(&GalleryWatchStateTracker::HandleSetupGalleryWatchResponse,
291 AsWeakPtr(), 289 AsWeakPtr(),
292 extension_id, 290 extension_id,
293 gallery_id)); 291 gallery_id));
294 } 292 }
295 293
296 void GalleryWatchStateTracker::RemoveGalleryWatch( 294 void GalleryWatchStateTracker::RemoveGalleryWatch(
297 const std::string& extension_id, 295 const std::string& extension_id,
298 chrome::MediaGalleryPrefId gallery_id, 296 MediaGalleryPrefId gallery_id,
299 chrome::MediaGalleriesPreferences* preferences) { 297 MediaGalleriesPreferences* preferences) {
300 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 298 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
301 const Extension* extension = GetExtensionById(profile_, extension_id); 299 const Extension* extension = GetExtensionById(profile_, extension_id);
302 DCHECK(extension); 300 DCHECK(extension);
303 base::FilePath gallery_file_path(preferences->LookUpGalleryPathForExtension( 301 base::FilePath gallery_file_path(preferences->LookUpGalleryPathForExtension(
304 gallery_id, extension, true)); 302 gallery_id, extension, true));
305 if (gallery_file_path.empty()) 303 if (gallery_file_path.empty())
306 return; 304 return;
307 content::BrowserThread::PostTask( 305 content::BrowserThread::PostTask(
308 content::BrowserThread::FILE, FROM_HERE, 306 content::BrowserThread::FILE, FROM_HERE,
309 base::Bind(&GalleryWatchManager::RemoveGalleryWatch, 307 base::Bind(&GalleryWatchManager::RemoveGalleryWatch,
310 profile_, 308 profile_,
311 gallery_file_path, 309 gallery_file_path,
312 extension_id)); 310 extension_id));
313 watched_extensions_map_[extension_id][gallery_id] = false; 311 watched_extensions_map_[extension_id][gallery_id] = false;
314 } 312 }
315 313
316 bool GalleryWatchStateTracker::HasGalleryWatchInfo( 314 bool GalleryWatchStateTracker::HasGalleryWatchInfo(
317 const std::string& extension_id, 315 const std::string& extension_id,
318 chrome::MediaGalleryPrefId gallery_id, 316 MediaGalleryPrefId gallery_id,
319 bool has_active_watcher) { 317 bool has_active_watcher) {
320 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 318 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
321 return (ContainsKey(watched_extensions_map_, extension_id) && 319 return (ContainsKey(watched_extensions_map_, extension_id) &&
322 ContainsKey(watched_extensions_map_[extension_id], gallery_id) && 320 ContainsKey(watched_extensions_map_[extension_id], gallery_id) &&
323 watched_extensions_map_[extension_id][gallery_id] == 321 watched_extensions_map_[extension_id][gallery_id] ==
324 has_active_watcher); 322 has_active_watcher);
325 } 323 }
326 324
327 void GalleryWatchStateTracker::HandleSetupGalleryWatchResponse( 325 void GalleryWatchStateTracker::HandleSetupGalleryWatchResponse(
328 const std::string& extension_id, 326 const std::string& extension_id,
329 chrome::MediaGalleryPrefId gallery_id, 327 MediaGalleryPrefId gallery_id,
330 bool success) { 328 bool success) {
331 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 329 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
332 if (!success) 330 if (!success)
333 return; // Failed to setup the gallery watch for the given extension. 331 return; // Failed to setup the gallery watch for the given extension.
334 AddWatchedGalleryIdInfoForExtension(extension_id, gallery_id); 332 AddWatchedGalleryIdInfoForExtension(extension_id, gallery_id);
335 } 333 }
336 334
337 bool GalleryWatchStateTracker::AddWatchedGalleryIdInfoForExtension( 335 bool GalleryWatchStateTracker::AddWatchedGalleryIdInfoForExtension(
338 const std::string& extension_id, 336 const std::string& extension_id,
339 chrome::MediaGalleryPrefId gallery_id) { 337 MediaGalleryPrefId gallery_id) {
340 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 338 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
341 if (HasGalleryWatchInfo(extension_id, gallery_id, true)) 339 if (HasGalleryWatchInfo(extension_id, gallery_id, true))
342 return false; 340 return false;
343 watched_extensions_map_[extension_id][gallery_id] = true; 341 watched_extensions_map_[extension_id][gallery_id] = true;
344 return true; 342 return true;
345 } 343 }
346 344
347 } // namespace extensions 345 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698