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

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

Issue 440813002: Expose gallery watching functionality to the public mediaGalleries API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix race condition in the apitest. Created 6 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
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 #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_ private_api.h" 5 #include "chrome/browser/extensions/api/media_galleries_private/media_galleries_ private_api.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 const char kInvalidGalleryIDError[] = "Invalid gallery ID"; 43 const char kInvalidGalleryIDError[] = "Invalid gallery ID";
44 44
45 // Handles the profile shutdown event on the file thread to clean up 45 // Handles the profile shutdown event on the file thread to clean up
46 // GalleryWatchManager. 46 // GalleryWatchManager.
47 void HandleProfileShutdownOnFileThread(void* profile_id) { 47 void HandleProfileShutdownOnFileThread(void* profile_id) {
48 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); 48 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
49 GalleryWatchManager::OnProfileShutdown(profile_id); 49 GalleryWatchManager::OnProfileShutdown(profile_id);
50 } 50 }
51 51
52 // Gets the |gallery_file_path| and |gallery_pref_id| of the gallery specified 52 // Returns true and sets |gallery_file_path| and |gallery_pref_id| if the
53 // by the |gallery_id|. Returns true and set |gallery_file_path| and 53 // |gallery_id| is valid and returns false otherwise.
54 // |gallery_pref_id| if the |gallery_id| is valid and returns false otherwise.
55 bool GetGalleryFilePathAndId(const std::string& gallery_id, 54 bool GetGalleryFilePathAndId(const std::string& gallery_id,
56 Profile* profile, 55 Profile* profile,
57 const Extension* extension, 56 const Extension* extension,
58 base::FilePath* gallery_file_path, 57 base::FilePath* gallery_file_path,
59 MediaGalleryPrefId* gallery_pref_id) { 58 MediaGalleryPrefId* gallery_pref_id) {
60 MediaGalleryPrefId pref_id; 59 MediaGalleryPrefId pref_id;
61 if (!base::StringToUint64(gallery_id, &pref_id)) 60 if (!base::StringToUint64(gallery_id, &pref_id))
62 return false; 61 return false;
63 MediaGalleriesPreferences* preferences = 62 MediaGalleriesPreferences* preferences =
64 g_browser_process->media_file_system_registry()->GetPreferences(profile); 63 g_browser_process->media_file_system_registry()->GetPreferences(profile);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 g_browser_process->media_file_system_registry()->GetPreferences( 350 g_browser_process->media_file_system_registry()->GetPreferences(
352 GetProfile()); 351 GetProfile());
353 GalleryWatchStateTracker* state_tracker = MediaGalleriesPrivateAPI::Get( 352 GalleryWatchStateTracker* state_tracker = MediaGalleriesPrivateAPI::Get(
354 GetProfile())->GetGalleryWatchStateTracker(); 353 GetProfile())->GetGalleryWatchStateTracker();
355 state_tracker->RemoveAllGalleryWatchersForExtension( 354 state_tracker->RemoveAllGalleryWatchersForExtension(
356 extension_id(), preferences); 355 extension_id(), preferences);
357 SendResponse(true); 356 SendResponse(true);
358 } 357 }
359 358
360 } // namespace extensions 359 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/media_galleries/media_galleries_watch_apitest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698