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

Side by Side Diff: chrome/browser/media_galleries/fileapi/picasa_finder.cc

Issue 23513059: Media Galleries API Picasa: End-to-end browsertest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/media_galleries/fileapi/picasa_finder.h" 5 #include "chrome/browser/media_galleries/fileapi/picasa_finder.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "chrome/browser/storage_monitor/storage_info.h" 12 #include "chrome/browser/storage_monitor/storage_info.h"
12 #include "chrome/common/media_galleries/picasa_types.h" 13 #include "chrome/common/media_galleries/picasa_types.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 15
15 namespace picasa { 16 namespace picasa {
16 17
17 namespace { 18 namespace {
18 19
19 // Returns path of Picasa's DB3 database directory. May only be called on 20 // Returns path of Picasa's DB3 database directory. May only be called on
20 // threads that allow for disk IO, like the FILE thread or MediaTaskRunner. 21 // threads that allow for disk IO, like the FILE thread or MediaTaskRunner.
21 base::FilePath FindPicasaDatabaseOnFileThread() { 22 base::FilePath FindPicasaDatabaseOnFileThread() {
22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 23 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
23 base::FilePath path; 24 base::FilePath path;
24 25
25 #if defined(OS_WIN) 26 #if defined(OS_WIN)
26 // TODO(tommycli): Check registry for alternative path. 27 // TODO(tommycli): Check registry for alternative path.
27 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &path)) 28 if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &path))
28 return base::FilePath(); 29 return base::FilePath();
29 #elif defined(OS_MACOSX) 30 #elif defined(OS_MACOSX)
30 // TODO(tommycli): Check Mac Preferences for alternative path. 31 // TODO(tommycli): Check Mac Preferences for alternative path.
31 if (!PathService::Get(base::DIR_APP_DATA, &path)) 32 if (!PathService::Get(base::DIR_APP_DATA, &path))
32 return base::FilePath(); 33 return base::FilePath();
33 #else 34 #else
34 return base::FilePath(); 35 return base::FilePath();
35 #endif 36 #endif
36 37
37 path = path.AppendASCII("Google").AppendASCII("Picasa2") 38 path = path.AppendASCII("Google").AppendASCII("Picasa2").AppendASCII(
38 .AppendASCII(kPicasaDatabaseDirName); 39 kPicasaDatabaseDirName);
39 40
40 // Verify actual existence 41 // Verify actual existence
41 if (!base::DirectoryExists(path)) 42 if (!base::DirectoryExists(path))
42 path.clear(); 43 path.clear();
43 44
44 return path; 45 return path;
45 } 46 }
46 47
47 void FinishOnOriginalThread(const PicasaFinder::DeviceIDCallback& callback, 48 void FinishOnOriginalThread(const DeviceIDCallback& callback,
48 const base::FilePath& database_path) { 49 const base::FilePath& database_path) {
49 std::string device_id; 50 std::string device_id;
50 if (!database_path.empty()) { 51 if (!database_path.empty()) {
51 device_id = StorageInfo::MakeDeviceId(StorageInfo::PICASA, 52 device_id = StorageInfo::MakeDeviceId(StorageInfo::PICASA,
52 database_path.AsUTF8Unsafe()); 53 database_path.AsUTF8Unsafe());
53 } 54 }
54 callback.Run(device_id); 55 callback.Run(device_id);
55 } 56 }
56 57
57 } // namespace 58 } // namespace
58 59
59 void PicasaFinder::FindPicasaDatabase( 60 void FindPicasaDatabase(const DeviceIDCallback& callback) {
60 const PicasaFinder::DeviceIDCallback& callback) {
61 content::BrowserThread::PostTaskAndReplyWithResult( 61 content::BrowserThread::PostTaskAndReplyWithResult(
62 content::BrowserThread::FILE, 62 content::BrowserThread::FILE,
63 FROM_HERE, 63 FROM_HERE,
64 base::Bind(&FindPicasaDatabaseOnFileThread), 64 base::Bind(&FindPicasaDatabaseOnFileThread),
65 base::Bind(&FinishOnOriginalThread, callback)); 65 base::Bind(&FinishOnOriginalThread, callback));
66 } 66 }
67 67
68 } // namespace picasa 68 } // namespace picasa
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/fileapi/picasa_finder.h ('k') | chrome/browser/media_galleries/media_galleries_preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698