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

Side by Side Diff: chrome/browser/chromeos/file_manager/fileapi_util.cc

Issue 1455403003: Add an option to specify requested fields for fetching metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleaned up. Created 5 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/chromeos/file_manager/fileapi_util.h" 5 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "chrome/browser/chromeos/drive/file_system_util.h" 9 #include "chrome/browser/chromeos/drive/file_system_util.h"
10 #include "chrome/browser/chromeos/file_manager/app_id.h" 10 #include "chrome/browser/chromeos/file_manager/app_id.h"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 return; 342 return;
343 } 343 }
344 344
345 if (!it->file_system_url.is_valid()) { 345 if (!it->file_system_url.is_valid()) {
346 FillMetadataOnIOThread(lifetime.Pass(), it + 1); 346 FillMetadataOnIOThread(lifetime.Pass(), it + 1);
347 return; 347 return;
348 } 348 }
349 349
350 context_->operation_runner()->GetMetadata( 350 context_->operation_runner()->GetMetadata(
351 context_->CrackURL(it->file_system_url), 351 context_->CrackURL(it->file_system_url),
352 storage::FileSystemOperation::GET_METADATA_FIELD_IS_DIRECTORY |
353 storage::FileSystemOperation::GET_METADATA_FIELD_SIZE |
354 storage::FileSystemOperation::GET_METADATA_FIELD_LAST_MODIFIED,
352 base::Bind(&ConvertSelectedFileInfoListToFileChooserFileInfoListImpl:: 355 base::Bind(&ConvertSelectedFileInfoListToFileChooserFileInfoListImpl::
353 OnGotMetadataOnIOThread, 356 OnGotMetadataOnIOThread,
354 base::Unretained(this), 357 base::Unretained(this), base::Passed(&lifetime), it));
355 base::Passed(&lifetime),
356 it));
357 } 358 }
358 359
359 // Callback invoked after GetMetadata. 360 // Callback invoked after GetMetadata.
360 void OnGotMetadataOnIOThread(Lifetime lifetime, 361 void OnGotMetadataOnIOThread(Lifetime lifetime,
361 const FileChooserFileInfoList::iterator& it, 362 const FileChooserFileInfoList::iterator& it,
362 base::File::Error result, 363 base::File::Error result,
363 const base::File::Info& file_info) { 364 const base::File::Info& file_info) {
364 DCHECK_CURRENTLY_ON(BrowserThread::IO); 365 DCHECK_CURRENTLY_ON(BrowserThread::IO);
365 366
366 if (result != base::File::FILE_OK) { 367 if (result != base::File::FILE_OK) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 BrowserThread::IO, FROM_HERE, 548 BrowserThread::IO, FROM_HERE,
548 base::Bind(base::IgnoreResult( 549 base::Bind(base::IgnoreResult(
549 &storage::FileSystemOperationRunner::DirectoryExists), 550 &storage::FileSystemOperationRunner::DirectoryExists),
550 file_system_context->operation_runner()->AsWeakPtr(), 551 file_system_context->operation_runner()->AsWeakPtr(),
551 internal_url, google_apis::CreateRelayCallback(callback))); 552 internal_url, google_apis::CreateRelayCallback(callback)));
552 } 553 }
553 554
554 void GetMetadataForPath( 555 void GetMetadataForPath(
555 scoped_refptr<storage::FileSystemContext> file_system_context, 556 scoped_refptr<storage::FileSystemContext> file_system_context,
556 const base::FilePath& entry_path, 557 const base::FilePath& entry_path,
558 int fields,
557 const storage::FileSystemOperationRunner::GetMetadataCallback& callback) { 559 const storage::FileSystemOperationRunner::GetMetadataCallback& callback) {
558 DCHECK_CURRENTLY_ON(BrowserThread::UI); 560 DCHECK_CURRENTLY_ON(BrowserThread::UI);
559 561
560 storage::ExternalFileSystemBackend* const backend = 562 storage::ExternalFileSystemBackend* const backend =
561 file_system_context->external_backend(); 563 file_system_context->external_backend();
562 DCHECK(backend); 564 DCHECK(backend);
563 const storage::FileSystemURL internal_url = 565 const storage::FileSystemURL internal_url =
564 backend->CreateInternalURL(file_system_context.get(), entry_path); 566 backend->CreateInternalURL(file_system_context.get(), entry_path);
565 567
566 BrowserThread::PostTask( 568 BrowserThread::PostTask(
567 BrowserThread::IO, FROM_HERE, 569 BrowserThread::IO, FROM_HERE,
568 base::Bind( 570 base::Bind(
569 base::IgnoreResult(&storage::FileSystemOperationRunner::GetMetadata), 571 base::IgnoreResult(&storage::FileSystemOperationRunner::GetMetadata),
570 file_system_context->operation_runner()->AsWeakPtr(), internal_url, 572 file_system_context->operation_runner()->AsWeakPtr(), internal_url,
571 google_apis::CreateRelayCallback(callback))); 573 fields, google_apis::CreateRelayCallback(callback)));
572 } 574 }
573 575
574 storage::FileSystemURL CreateIsolatedURLFromVirtualPath( 576 storage::FileSystemURL CreateIsolatedURLFromVirtualPath(
575 const storage::FileSystemContext& context, 577 const storage::FileSystemContext& context,
576 const GURL& origin, 578 const GURL& origin,
577 const base::FilePath& virtual_path) { 579 const base::FilePath& virtual_path) {
578 const storage::FileSystemURL original_url = 580 const storage::FileSystemURL original_url =
579 context.CreateCrackedFileSystemURL( 581 context.CreateCrackedFileSystemURL(
580 origin, storage::kFileSystemTypeExternal, virtual_path); 582 origin, storage::kFileSystemTypeExternal, virtual_path);
581 583
582 std::string register_name; 584 std::string register_name;
583 const std::string isolated_file_system_id = 585 const std::string isolated_file_system_id =
584 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath( 586 storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath(
585 original_url.type(), 587 original_url.type(),
586 original_url.filesystem_id(), 588 original_url.filesystem_id(),
587 original_url.path(), 589 original_url.path(),
588 &register_name); 590 &register_name);
589 const storage::FileSystemURL isolated_url = 591 const storage::FileSystemURL isolated_url =
590 context.CreateCrackedFileSystemURL( 592 context.CreateCrackedFileSystemURL(
591 origin, 593 origin,
592 storage::kFileSystemTypeIsolated, 594 storage::kFileSystemTypeIsolated,
593 base::FilePath(isolated_file_system_id).Append(register_name)); 595 base::FilePath(isolated_file_system_id).Append(register_name));
594 return isolated_url; 596 return isolated_url;
595 } 597 }
596 598
597 } // namespace util 599 } // namespace util
598 } // namespace file_manager 600 } // namespace file_manager
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/file_manager/fileapi_util.h ('k') | chrome/browser/chromeos/file_manager/open_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698