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

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

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

Powered by Google App Engine
This is Rietveld 408576698