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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc

Issue 10836354: Rename GData* to Drive* in gdata.proto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase. Created 8 years, 4 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/gdata/gdata_file_system_proxy.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/platform_file.h" 11 #include "base/platform_file.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/chromeos/gdata/gdata.pb.h" 14 #include "chrome/browser/chromeos/gdata/drive.pb.h"
15 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" 15 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h"
16 #include "chrome/browser/chromeos/gdata/gdata_files.h" 16 #include "chrome/browser/chromeos/gdata/gdata_files.h"
17 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" 17 #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
18 #include "chrome/browser/chromeos/gdata/gdata_util.h" 18 #include "chrome/browser/chromeos/gdata/gdata_util.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "webkit/blob/shareable_file_reference.h" 20 #include "webkit/blob/shareable_file_reference.h"
21 #include "webkit/fileapi/file_system_file_util_proxy.h" 21 #include "webkit/fileapi/file_system_file_util_proxy.h"
22 #include "webkit/fileapi/file_system_types.h" 22 #include "webkit/fileapi/file_system_types.h"
23 #include "webkit/fileapi/file_system_url.h" 23 #include "webkit/fileapi/file_system_url.h"
24 #include "webkit/fileapi/file_system_util.h" 24 #include "webkit/fileapi/file_system_util.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 base::PlatformFileError truncate_result, 156 base::PlatformFileError truncate_result,
157 GDataFileError close_result) { 157 GDataFileError close_result) {
158 // Reports the first error. 158 // Reports the first error.
159 callback.Run(truncate_result == base::PLATFORM_FILE_OK ? 159 callback.Run(truncate_result == base::PLATFORM_FILE_OK ?
160 util::GDataFileErrorToPlatformError(close_result) : 160 util::GDataFileErrorToPlatformError(close_result) :
161 truncate_result); 161 truncate_result);
162 } 162 }
163 163
164 } // namespace 164 } // namespace
165 165
166 base::FileUtilProxy::Entry GDataEntryProtoToFileUtilProxyEntry( 166 base::FileUtilProxy::Entry DriveEntryProtoToFileUtilProxyEntry(
167 const GDataEntryProto& proto) { 167 const DriveEntryProto& proto) {
168 base::PlatformFileInfo file_info; 168 base::PlatformFileInfo file_info;
169 GDataEntry::ConvertProtoToPlatformFileInfo(proto.file_info(), &file_info); 169 GDataEntry::ConvertProtoToPlatformFileInfo(proto.file_info(), &file_info);
170 170
171 base::FileUtilProxy::Entry entry; 171 base::FileUtilProxy::Entry entry;
172 entry.name = proto.base_name(); 172 entry.name = proto.base_name();
173 entry.is_directory = file_info.is_directory; 173 entry.is_directory = file_info.is_directory;
174 entry.size = file_info.size; 174 entry.size = file_info.size;
175 entry.last_modified_time = file_info.last_modified; 175 entry.last_modified_time = file_info.last_modified;
176 return entry; 176 return entry;
177 } 177 }
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 base::Bind(&GDataFileSystemProxy::OnGetEntryInfoByPath, 575 base::Bind(&GDataFileSystemProxy::OnGetEntryInfoByPath,
576 this, 576 this,
577 file_path, 577 file_path,
578 callback)); 578 callback));
579 } 579 }
580 580
581 void GDataFileSystemProxy::OnGetEntryInfoByPath( 581 void GDataFileSystemProxy::OnGetEntryInfoByPath(
582 const FilePath& entry_path, 582 const FilePath& entry_path,
583 const FileSystemOperationInterface::SnapshotFileCallback& callback, 583 const FileSystemOperationInterface::SnapshotFileCallback& callback,
584 GDataFileError error, 584 GDataFileError error,
585 scoped_ptr<GDataEntryProto> entry_proto) { 585 scoped_ptr<DriveEntryProto> entry_proto) {
586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
587 587
588 if (error != GDATA_FILE_OK || !entry_proto.get()) { 588 if (error != GDATA_FILE_OK || !entry_proto.get()) {
589 MessageLoopProxy::current()->PostTask(FROM_HERE, 589 MessageLoopProxy::current()->PostTask(FROM_HERE,
590 base::Bind(callback, 590 base::Bind(callback,
591 base::PLATFORM_FILE_ERROR_NOT_FOUND, 591 base::PLATFORM_FILE_ERROR_NOT_FOUND,
592 base::PlatformFileInfo(), 592 base::PlatformFileInfo(),
593 FilePath(), 593 FilePath(),
594 scoped_refptr<ShareableFileReference>(NULL))); 594 scoped_refptr<ShareableFileReference>(NULL)));
595 return; 595 return;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 void GDataFileSystemProxy::OnStatusCallback( 649 void GDataFileSystemProxy::OnStatusCallback(
650 const fileapi::FileSystemOperationInterface::StatusCallback& callback, 650 const fileapi::FileSystemOperationInterface::StatusCallback& callback,
651 GDataFileError error) { 651 GDataFileError error) {
652 callback.Run(util::GDataFileErrorToPlatformError(error)); 652 callback.Run(util::GDataFileErrorToPlatformError(error));
653 } 653 }
654 654
655 void GDataFileSystemProxy::OnGetMetadata( 655 void GDataFileSystemProxy::OnGetMetadata(
656 const FilePath& file_path, 656 const FilePath& file_path,
657 const FileSystemOperationInterface::GetMetadataCallback& callback, 657 const FileSystemOperationInterface::GetMetadataCallback& callback,
658 GDataFileError error, 658 GDataFileError error,
659 scoped_ptr<GDataEntryProto> entry_proto) { 659 scoped_ptr<DriveEntryProto> entry_proto) {
660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
661 661
662 if (error != GDATA_FILE_OK) { 662 if (error != GDATA_FILE_OK) {
663 callback.Run(util::GDataFileErrorToPlatformError(error), 663 callback.Run(util::GDataFileErrorToPlatformError(error),
664 base::PlatformFileInfo(), 664 base::PlatformFileInfo(),
665 FilePath()); 665 FilePath());
666 return; 666 return;
667 } 667 }
668 DCHECK(entry_proto.get()); 668 DCHECK(entry_proto.get());
669 669
670 base::PlatformFileInfo file_info; 670 base::PlatformFileInfo file_info;
671 GDataEntry::ConvertProtoToPlatformFileInfo( 671 GDataEntry::ConvertProtoToPlatformFileInfo(
672 entry_proto->file_info(), 672 entry_proto->file_info(),
673 &file_info); 673 &file_info);
674 674
675 callback.Run(base::PLATFORM_FILE_OK, file_info, file_path); 675 callback.Run(base::PLATFORM_FILE_OK, file_info, file_path);
676 } 676 }
677 677
678 void GDataFileSystemProxy::OnReadDirectory( 678 void GDataFileSystemProxy::OnReadDirectory(
679 const FileSystemOperationInterface::ReadDirectoryCallback& 679 const FileSystemOperationInterface::ReadDirectoryCallback&
680 callback, 680 callback,
681 GDataFileError error, 681 GDataFileError error,
682 bool hide_hosted_documents, 682 bool hide_hosted_documents,
683 scoped_ptr<GDataEntryProtoVector> proto_entries) { 683 scoped_ptr<DriveEntryProtoVector> proto_entries) {
684 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 684 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
685 685
686 if (error != GDATA_FILE_OK) { 686 if (error != GDATA_FILE_OK) {
687 callback.Run(util::GDataFileErrorToPlatformError(error), 687 callback.Run(util::GDataFileErrorToPlatformError(error),
688 std::vector<base::FileUtilProxy::Entry>(), 688 std::vector<base::FileUtilProxy::Entry>(),
689 false); 689 false);
690 return; 690 return;
691 } 691 }
692 DCHECK(proto_entries.get()); 692 DCHECK(proto_entries.get());
693 693
694 std::vector<base::FileUtilProxy::Entry> entries; 694 std::vector<base::FileUtilProxy::Entry> entries;
695 // Convert gdata files to something File API stack can understand. 695 // Convert gdata files to something File API stack can understand.
696 for (size_t i = 0; i < proto_entries->size(); ++i) { 696 for (size_t i = 0; i < proto_entries->size(); ++i) {
697 const GDataEntryProto& proto = (*proto_entries)[i]; 697 const DriveEntryProto& proto = (*proto_entries)[i];
698 if (proto.has_file_specific_info() && 698 if (proto.has_file_specific_info() &&
699 proto.file_specific_info().is_hosted_document() && 699 proto.file_specific_info().is_hosted_document() &&
700 hide_hosted_documents) { 700 hide_hosted_documents) {
701 continue; 701 continue;
702 } 702 }
703 entries.push_back(GDataEntryProtoToFileUtilProxyEntry(proto)); 703 entries.push_back(DriveEntryProtoToFileUtilProxyEntry(proto));
704 } 704 }
705 705
706 callback.Run(base::PLATFORM_FILE_OK, entries, false); 706 callback.Run(base::PLATFORM_FILE_OK, entries, false);
707 } 707 }
708 708
709 void GDataFileSystemProxy::OnCreateWritableSnapshotFile( 709 void GDataFileSystemProxy::OnCreateWritableSnapshotFile(
710 const FilePath& virtual_path, 710 const FilePath& virtual_path,
711 const fileapi::WritableSnapshotFile& callback, 711 const fileapi::WritableSnapshotFile& callback,
712 GDataFileError result, 712 GDataFileError result,
713 const FilePath& local_path) { 713 const FilePath& local_path) {
(...skipping 19 matching lines...) Expand all
733 void GDataFileSystemProxy::CloseWritableSnapshotFile( 733 void GDataFileSystemProxy::CloseWritableSnapshotFile(
734 const FilePath& virtual_path, 734 const FilePath& virtual_path,
735 const FilePath& local_path) { 735 const FilePath& local_path) {
736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 736 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
737 737
738 file_system_->CloseFile(virtual_path, 738 file_system_->CloseFile(virtual_path,
739 base::Bind(&EmitDebugLogForCloseFile, virtual_path)); 739 base::Bind(&EmitDebugLogForCloseFile, virtual_path));
740 } 740 }
741 741
742 } // namespace gdata 742 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698