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

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

Issue 2518053002: Always delete media galleries FilePathWatchers on the FILE thread. (Closed)
Patch Set: fix build error Created 4 years, 1 month 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 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/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_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"
15 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" 14 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
16 #include "chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader. h" 15 #include "chrome/browser/media_galleries/fileapi/safe_picasa_album_table_reader. h"
17 #include "chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h" 16 #include "chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h"
18 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" 17 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h"
19 #include "storage/browser/fileapi/file_system_operation_context.h" 18 #include "storage/browser/fileapi/file_system_operation_context.h"
20 #include "storage/browser/fileapi/file_system_url.h" 19 #include "storage/browser/fileapi/file_system_url.h"
21 20
22 namespace picasa { 21 namespace picasa {
23 22
24 namespace { 23 namespace {
(...skipping 19 matching lines...) Expand all
44 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); 43 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence();
45 44
46 StartFilePathWatchOnMediaTaskRunner( 45 StartFilePathWatchOnMediaTaskRunner(
47 database_path_.DirName().AppendASCII(kPicasaTempDirName), 46 database_path_.DirName().AppendASCII(kPicasaTempDirName),
48 base::Bind(&PicasaDataProvider::OnTempDirWatchStarted, 47 base::Bind(&PicasaDataProvider::OnTempDirWatchStarted,
49 weak_factory_.GetWeakPtr()), 48 weak_factory_.GetWeakPtr()),
50 base::Bind(&PicasaDataProvider::OnTempDirChanged, 49 base::Bind(&PicasaDataProvider::OnTempDirChanged,
51 weak_factory_.GetWeakPtr())); 50 weak_factory_.GetWeakPtr()));
52 } 51 }
53 52
54 PicasaDataProvider::~PicasaDataProvider() { 53 PicasaDataProvider::~PicasaDataProvider() {}
55 StopFilePathWatchOnMediaTaskRunner(std::move(temp_dir_watcher_));
56 }
57 54
58 void PicasaDataProvider::RefreshData(DataType needed_data, 55 void PicasaDataProvider::RefreshData(DataType needed_data,
59 const ReadyCallback& ready_callback) { 56 const ReadyCallback& ready_callback) {
60 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); 57 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence();
61 // TODO(tommycli): Need to watch the database_path_ folder and handle 58 // TODO(tommycli): Need to watch the database_path_ folder and handle
62 // rereading the data when it changes. 59 // rereading the data when it changes.
63 60
64 if (state_ == INVALID_DATA_STATE) { 61 if (state_ == INVALID_DATA_STATE) {
65 ready_callback.Run(false /* success */); 62 ready_callback.Run(false /* success */);
66 return; 63 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // TODO(tommycli): Implement and call Cancel function for these 119 // TODO(tommycli): Implement and call Cancel function for these
123 // UtilityProcessHostClients to actually kill the in-flight processes. 120 // UtilityProcessHostClients to actually kill the in-flight processes.
124 state_ = STALE_DATA_STATE; 121 state_ = STALE_DATA_STATE;
125 album_table_reader_ = NULL; 122 album_table_reader_ = NULL;
126 albums_indexer_ = NULL; 123 albums_indexer_ = NULL;
127 124
128 DoRefreshIfNecessary(); 125 DoRefreshIfNecessary();
129 } 126 }
130 127
131 void PicasaDataProvider::OnTempDirWatchStarted( 128 void PicasaDataProvider::OnTempDirWatchStarted(
132 std::unique_ptr<base::FilePathWatcher> temp_dir_watcher) { 129 MediaFilePathWatcherUniquePtr temp_dir_watcher) {
133 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); 130 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence();
134 temp_dir_watcher_ = std::move(temp_dir_watcher); 131 temp_dir_watcher_ = std::move(temp_dir_watcher);
135 } 132 }
136 133
137 void PicasaDataProvider::OnTempDirChanged(const base::FilePath& temp_dir_path, 134 void PicasaDataProvider::OnTempDirChanged(const base::FilePath& temp_dir_path,
138 bool error) { 135 bool error) {
139 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence(); 136 MediaFileSystemBackend::AssertCurrentlyOnMediaSequence();
140 if (base::IsDirectoryEmpty(temp_dir_path)) 137 if (base::IsDirectoryEmpty(temp_dir_path))
141 InvalidateData(); 138 InvalidateData();
142 } 139 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 if (total_counts[name] != 1) { 257 if (total_counts[name] != 1) {
261 name = base::StringPrintf("%s (%d)", name.c_str(), 258 name = base::StringPrintf("%s (%d)", name.c_str(),
262 ++current_counts[name]); 259 ++current_counts[name]);
263 } 260 }
264 261
265 result_map->insert(std::pair<std::string, AlbumInfo>(name, info_list[i])); 262 result_map->insert(std::pair<std::string, AlbumInfo>(name, info_list[i]));
266 } 263 }
267 } 264 }
268 265
269 } // namespace picasa 266 } // namespace picasa
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698