| OLD | NEW |
| 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_data_provider.h" | 5 #include "chrome/browser/media_galleries/fileapi/picasa_data_provider.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "chrome/browser/media_galleries/fileapi/file_path_watcher_util.h" | 14 #include "chrome/browser/media_galleries/fileapi/file_path_watcher_util.h" |
| 15 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 15 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
| 16 #include "chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.
h" | 16 #include "chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader.
h" |
| 17 #include "chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h" | 17 #include "chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h" |
| 18 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" | 18 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" |
| 19 #include "webkit/browser/fileapi/file_system_operation_context.h" | 19 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 20 #include "webkit/browser/fileapi/file_system_url.h" | 20 #include "webkit/browser/fileapi/file_system_url.h" |
| 21 | 21 |
| 22 using chrome::MediaFileSystemBackend; | |
| 23 | |
| 24 namespace picasa { | 22 namespace picasa { |
| 25 | 23 |
| 26 namespace { | 24 namespace { |
| 27 | 25 |
| 28 void RunAllCallbacks( | 26 void RunAllCallbacks( |
| 29 std::queue<PicasaDataProvider::ReadyCallback>* ready_callbacks_queue, | 27 std::queue<PicasaDataProvider::ReadyCallback>* ready_callbacks_queue, |
| 30 bool success) { | 28 bool success) { |
| 31 while (!ready_callbacks_queue->empty()) { | 29 while (!ready_callbacks_queue->empty()) { |
| 32 ready_callbacks_queue->front().Run(success); | 30 ready_callbacks_queue->front().Run(success); |
| 33 ready_callbacks_queue->pop(); | 31 ready_callbacks_queue->pop(); |
| 34 } | 32 } |
| 35 } | 33 } |
| 36 | 34 |
| 37 } // namespace | 35 } // namespace |
| 38 | 36 |
| 39 PicasaDataProvider::PicasaDataProvider(const base::FilePath& database_path) | 37 PicasaDataProvider::PicasaDataProvider(const base::FilePath& database_path) |
| 40 : database_path_(database_path), | 38 : database_path_(database_path), |
| 41 state_(STALE_DATA_STATE), | 39 state_(STALE_DATA_STATE), |
| 42 weak_factory_(this) { | 40 weak_factory_(this) { |
| 43 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | 41 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); |
| 44 | 42 |
| 45 chrome::StartFilePathWatchOnMediaTaskRunner( | 43 StartFilePathWatchOnMediaTaskRunner( |
| 46 database_path_.DirName().AppendASCII(kPicasaTempDirName), | 44 database_path_.DirName().AppendASCII(kPicasaTempDirName), |
| 47 base::Bind(&PicasaDataProvider::OnTempDirWatchStarted, | 45 base::Bind(&PicasaDataProvider::OnTempDirWatchStarted, |
| 48 weak_factory_.GetWeakPtr()), | 46 weak_factory_.GetWeakPtr()), |
| 49 base::Bind(&PicasaDataProvider::OnTempDirChanged, | 47 base::Bind(&PicasaDataProvider::OnTempDirChanged, |
| 50 weak_factory_.GetWeakPtr())); | 48 weak_factory_.GetWeakPtr())); |
| 51 } | 49 } |
| 52 | 50 |
| 53 PicasaDataProvider::~PicasaDataProvider() {} | 51 PicasaDataProvider::~PicasaDataProvider() {} |
| 54 | 52 |
| 55 void PicasaDataProvider::RefreshData(DataType needed_data, | 53 void PicasaDataProvider::RefreshData(DataType needed_data, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 if (total_counts[name] != 1) { | 255 if (total_counts[name] != 1) { |
| 258 name = base::StringPrintf("%s (%d)", name.c_str(), | 256 name = base::StringPrintf("%s (%d)", name.c_str(), |
| 259 ++current_counts[name]); | 257 ++current_counts[name]); |
| 260 } | 258 } |
| 261 | 259 |
| 262 result_map->insert(std::pair<std::string, AlbumInfo>(name, info_list[i])); | 260 result_map->insert(std::pair<std::string, AlbumInfo>(name, info_list[i])); |
| 263 } | 261 } |
| 264 } | 262 } |
| 265 | 263 |
| 266 } // namespace picasa | 264 } // namespace picasa |
| OLD | NEW |