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

Side by Side Diff: chrome/browser/chromeos/drive/file_system.cc

Issue 16068004: drive: Rename file_system::DriveOperations to file_system::Operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 (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/chromeos/drive/file_system.h" 5 #include "chrome/browser/chromeos/drive/file_system.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 resource_metadata_->ResetOnUIThread(base::Bind( 211 resource_metadata_->ResetOnUIThread(base::Bind(
212 &FileSystem::ReloadAfterReset, 212 &FileSystem::ReloadAfterReset,
213 weak_ptr_factory_.GetWeakPtr())); 213 weak_ptr_factory_.GetWeakPtr()));
214 } 214 }
215 215
216 void FileSystem::Initialize() { 216 void FileSystem::Initialize() {
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
218 218
219 SetupChangeListLoader(); 219 SetupChangeListLoader();
220 220
221 // Allocate the drive operation handlers. 221 // Allocate the file system operation handlers.
222 drive_operations_.Init(this, // OperationObserver 222 operations_.Init(this, // OperationObserver
223 scheduler_, 223 scheduler_,
224 resource_metadata_, 224 resource_metadata_,
225 cache_, 225 cache_,
226 this, // FileSystemInterface 226 this, // FileSystemInterface
227 drive_service_, 227 drive_service_,
228 blocking_task_runner_); 228 blocking_task_runner_);
229 229
230 PrefService* pref_service = profile_->GetPrefs(); 230 PrefService* pref_service = profile_->GetPrefs();
231 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableDriveHostedFiles); 231 hide_hosted_docs_ = pref_service->GetBoolean(prefs::kDisableDriveHostedFiles);
232 232
233 InitializePreferenceObserver(); 233 InitializePreferenceObserver();
234 } 234 }
235 235
236 void FileSystem::ReloadAfterReset(FileError error) { 236 void FileSystem::ReloadAfterReset(FileError error) {
237 if (error != FILE_ERROR_OK) { 237 if (error != FILE_ERROR_OK) {
238 LOG(ERROR) << "Failed to reset the resource metadata: " 238 LOG(ERROR) << "Failed to reset the resource metadata: "
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 base::Bind(&RunGetResourceEntryWithFilePathCallback, 323 base::Bind(&RunGetResourceEntryWithFilePathCallback,
324 callback, 324 callback,
325 file_path)); 325 file_path));
326 } 326 }
327 327
328 void FileSystem::TransferFileFromRemoteToLocal( 328 void FileSystem::TransferFileFromRemoteToLocal(
329 const base::FilePath& remote_src_file_path, 329 const base::FilePath& remote_src_file_path,
330 const base::FilePath& local_dest_file_path, 330 const base::FilePath& local_dest_file_path,
331 const FileOperationCallback& callback) { 331 const FileOperationCallback& callback) {
332 332
333 drive_operations_.TransferFileFromRemoteToLocal(remote_src_file_path, 333 operations_.TransferFileFromRemoteToLocal(remote_src_file_path,
334 local_dest_file_path, 334 local_dest_file_path,
335 callback); 335 callback);
336 } 336 }
337 337
338 void FileSystem::TransferFileFromLocalToRemote( 338 void FileSystem::TransferFileFromLocalToRemote(
339 const base::FilePath& local_src_file_path, 339 const base::FilePath& local_src_file_path,
340 const base::FilePath& remote_dest_file_path, 340 const base::FilePath& remote_dest_file_path,
341 const FileOperationCallback& callback) { 341 const FileOperationCallback& callback) {
342 342
343 drive_operations_.TransferFileFromLocalToRemote(local_src_file_path, 343 operations_.TransferFileFromLocalToRemote(local_src_file_path,
344 remote_dest_file_path, 344 remote_dest_file_path,
345 callback); 345 callback);
346 } 346 }
347 347
348 void FileSystem::Copy(const base::FilePath& src_file_path, 348 void FileSystem::Copy(const base::FilePath& src_file_path,
349 const base::FilePath& dest_file_path, 349 const base::FilePath& dest_file_path,
350 const FileOperationCallback& callback) { 350 const FileOperationCallback& callback) {
351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
352 DCHECK(!callback.is_null()); 352 DCHECK(!callback.is_null());
353 drive_operations_.Copy(src_file_path, dest_file_path, callback); 353 operations_.Copy(src_file_path, dest_file_path, callback);
354 } 354 }
355 355
356 void FileSystem::Move(const base::FilePath& src_file_path, 356 void FileSystem::Move(const base::FilePath& src_file_path,
357 const base::FilePath& dest_file_path, 357 const base::FilePath& dest_file_path,
358 const FileOperationCallback& callback) { 358 const FileOperationCallback& callback) {
359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 359 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
360 DCHECK(!callback.is_null()); 360 DCHECK(!callback.is_null());
361 drive_operations_.Move(src_file_path, dest_file_path, callback); 361 operations_.Move(src_file_path, dest_file_path, callback);
362 } 362 }
363 363
364 void FileSystem::Remove(const base::FilePath& file_path, 364 void FileSystem::Remove(const base::FilePath& file_path,
365 bool is_recursive, 365 bool is_recursive,
366 const FileOperationCallback& callback) { 366 const FileOperationCallback& callback) {
367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
368 DCHECK(!callback.is_null()); 368 DCHECK(!callback.is_null());
369 drive_operations_.Remove(file_path, is_recursive, callback); 369 operations_.Remove(file_path, is_recursive, callback);
370 } 370 }
371 371
372 void FileSystem::CreateDirectory( 372 void FileSystem::CreateDirectory(
373 const base::FilePath& directory_path, 373 const base::FilePath& directory_path,
374 bool is_exclusive, 374 bool is_exclusive,
375 bool is_recursive, 375 bool is_recursive,
376 const FileOperationCallback& callback) { 376 const FileOperationCallback& callback) {
377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
378 DCHECK(!callback.is_null()); 378 DCHECK(!callback.is_null());
379 379
(...skipping 11 matching lines...) Expand all
391 const FileOperationCallback& callback, 391 const FileOperationCallback& callback,
392 FileError load_error) { 392 FileError load_error) {
393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
394 DCHECK(!callback.is_null()); 394 DCHECK(!callback.is_null());
395 395
396 if (load_error != FILE_ERROR_OK) { 396 if (load_error != FILE_ERROR_OK) {
397 callback.Run(load_error); 397 callback.Run(load_error);
398 return; 398 return;
399 } 399 }
400 400
401 drive_operations_.CreateDirectory( 401 operations_.CreateDirectory(
402 directory_path, is_exclusive, is_recursive, callback); 402 directory_path, is_exclusive, is_recursive, callback);
403 } 403 }
404 404
405 void FileSystem::CreateFile(const base::FilePath& file_path, 405 void FileSystem::CreateFile(const base::FilePath& file_path,
406 bool is_exclusive, 406 bool is_exclusive,
407 const FileOperationCallback& callback) { 407 const FileOperationCallback& callback) {
408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
409 DCHECK(!callback.is_null()); 409 DCHECK(!callback.is_null());
410 410
411 drive_operations_.CreateFile(file_path, is_exclusive, callback); 411 operations_.CreateFile(file_path, is_exclusive, callback);
412 } 412 }
413 413
414 void FileSystem::TouchFile(const base::FilePath& file_path, 414 void FileSystem::TouchFile(const base::FilePath& file_path,
415 const base::Time& last_access_time, 415 const base::Time& last_access_time,
416 const base::Time& last_modified_time, 416 const base::Time& last_modified_time,
417 const FileOperationCallback& callback) { 417 const FileOperationCallback& callback) {
418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
419 DCHECK(!last_access_time.is_null()); 419 DCHECK(!last_access_time.is_null());
420 DCHECK(!last_modified_time.is_null()); 420 DCHECK(!last_modified_time.is_null());
421 DCHECK(!callback.is_null()); 421 DCHECK(!callback.is_null());
422 422
423 drive_operations_.TouchFile( 423 operations_.TouchFile(
424 file_path, last_access_time, last_modified_time, callback); 424 file_path, last_access_time, last_modified_time, callback);
425 } 425 }
426 426
427 void FileSystem::Pin(const base::FilePath& file_path, 427 void FileSystem::Pin(const base::FilePath& file_path,
428 const FileOperationCallback& callback) { 428 const FileOperationCallback& callback) {
429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 429 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
430 DCHECK(!callback.is_null()); 430 DCHECK(!callback.is_null());
431 431
432 GetResourceEntryByPath(file_path, 432 GetResourceEntryByPath(file_path,
433 base::Bind(&FileSystem::PinAfterGetResourceEntryByPath, 433 base::Bind(&FileSystem::PinAfterGetResourceEntryByPath,
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 callback); 1147 callback);
1148 } 1148 }
1149 1149
1150 void FileSystem::UpdateFileByResourceId( 1150 void FileSystem::UpdateFileByResourceId(
1151 const std::string& resource_id, 1151 const std::string& resource_id,
1152 const DriveClientContext& context, 1152 const DriveClientContext& context,
1153 const FileOperationCallback& callback) { 1153 const FileOperationCallback& callback) {
1154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1155 DCHECK(!callback.is_null()); 1155 DCHECK(!callback.is_null());
1156 1156
1157 drive_operations_.UpdateFileByResourceId(resource_id, context, callback); 1157 operations_.UpdateFileByResourceId(resource_id, context, callback);
1158 } 1158 }
1159 1159
1160 void FileSystem::GetAvailableSpace( 1160 void FileSystem::GetAvailableSpace(
1161 const GetAvailableSpaceCallback& callback) { 1161 const GetAvailableSpaceCallback& callback) {
1162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1163 DCHECK(!callback.is_null()); 1163 DCHECK(!callback.is_null());
1164 1164
1165 scheduler_->GetAboutResource( 1165 scheduler_->GetAboutResource(
1166 base::Bind(&FileSystem::OnGetAboutResource, 1166 base::Bind(&FileSystem::OnGetAboutResource,
1167 weak_ptr_factory_.GetWeakPtr(), 1167 weak_ptr_factory_.GetWeakPtr(),
(...skipping 18 matching lines...) Expand all
1186 about_resource->quota_bytes_total(), 1186 about_resource->quota_bytes_total(),
1187 about_resource->quota_bytes_used()); 1187 about_resource->quota_bytes_used());
1188 } 1188 }
1189 1189
1190 void FileSystem::Search(const std::string& search_query, 1190 void FileSystem::Search(const std::string& search_query,
1191 const GURL& next_feed, 1191 const GURL& next_feed,
1192 const SearchCallback& callback) { 1192 const SearchCallback& callback) {
1193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1194 DCHECK(!callback.is_null()); 1194 DCHECK(!callback.is_null());
1195 1195
1196 drive_operations_.Search(search_query, next_feed, callback); 1196 operations_.Search(search_query, next_feed, callback);
1197 } 1197 }
1198 1198
1199 void FileSystem::SearchMetadata(const std::string& query, 1199 void FileSystem::SearchMetadata(const std::string& query,
1200 int options, 1200 int options,
1201 int at_most_num_matches, 1201 int at_most_num_matches,
1202 const SearchMetadataCallback& callback) { 1202 const SearchMetadataCallback& callback) {
1203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1204 1204
1205 if (hide_hosted_docs_) 1205 if (hide_hosted_docs_)
1206 options |= SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS; 1206 options |= SEARCH_METADATA_EXCLUDE_HOSTED_DOCUMENTS;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 util::ConvertPlatformFileInfoToResourceEntry(*file_info, &entry_file_info); 1645 util::ConvertPlatformFileInfoToResourceEntry(*file_info, &entry_file_info);
1646 *entry->mutable_file_info() = entry_file_info; 1646 *entry->mutable_file_info() = entry_file_info;
1647 callback.Run(FILE_ERROR_OK, entry.Pass()); 1647 callback.Run(FILE_ERROR_OK, entry.Pass());
1648 } 1648 }
1649 1649
1650 void FileSystem::CancelJobInScheduler(JobID id) { 1650 void FileSystem::CancelJobInScheduler(JobID id) {
1651 scheduler_->CancelJob(id); 1651 scheduler_->CancelJob(id);
1652 } 1652 }
1653 1653
1654 } // namespace drive 1654 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/file_system.h ('k') | chrome/browser/chromeos/drive/file_system/drive_operations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698