| OLD | NEW |
| 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_protocol_handler.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_protocol_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/threading/sequenced_worker_pool.h" | 18 #include "base/threading/sequenced_worker_pool.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
| 20 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | 21 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
| 21 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | |
| 22 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" | 22 #include "chrome/browser/chromeos/gdata/gdata_directory_service.h" |
| 23 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" | 23 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
| 24 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" | 24 #include "chrome/browser/chromeos/gdata/gdata_file_system_interface.h" |
| 25 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 25 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 26 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 26 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
| 29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 31 #include "net/base/escape.h" | 31 #include "net/base/escape.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 GDataFileType file_type); | 170 GDataFileType file_type); |
| 171 | 171 |
| 172 // Helper callback for GetFileSizeOnBlockingPool that sets |remaining_bytes_| | 172 // Helper callback for GetFileSizeOnBlockingPool that sets |remaining_bytes_| |
| 173 // to |file_size|, and notifies result for Start(). | 173 // to |file_size|, and notifies result for Start(). |
| 174 void OnGetFileSize(int64 *file_size); | 174 void OnGetFileSize(int64 *file_size); |
| 175 | 175 |
| 176 // Helper callback for GetEntryInfoByResourceId invoked by StartAsync. | 176 // Helper callback for GetEntryInfoByResourceId invoked by StartAsync. |
| 177 void OnGetEntryInfoByResourceId(const std::string& resource_id, | 177 void OnGetEntryInfoByResourceId(const std::string& resource_id, |
| 178 GDataFileError error, | 178 GDataFileError error, |
| 179 const FilePath& gdata_file_path, | 179 const FilePath& gdata_file_path, |
| 180 scoped_ptr<GDataEntryProto> entry_proto); | 180 scoped_ptr<DriveEntryProto> entry_proto); |
| 181 | 181 |
| 182 // Helper methods for ReadRawData to open file and read from its corresponding | 182 // Helper methods for ReadRawData to open file and read from its corresponding |
| 183 // stream in a streaming fashion. | 183 // stream in a streaming fashion. |
| 184 bool ContinueReadFromFile(int* bytes_read); | 184 bool ContinueReadFromFile(int* bytes_read); |
| 185 void ReadFromFile(); | 185 void ReadFromFile(); |
| 186 void ReadFileStream(int bytes_to_read); | 186 void ReadFileStream(int bytes_to_read); |
| 187 | 187 |
| 188 // Helper callback for handling async responses from FileStream::Open(). | 188 // Helper callback for handling async responses from FileStream::Open(). |
| 189 void OnFileOpen(int bytes_to_read, int open_result); | 189 void OnFileOpen(int bytes_to_read, int open_result); |
| 190 | 190 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 resource_id, | 504 resource_id, |
| 505 base::Bind(&GDataURLRequestJob::OnGetEntryInfoByResourceId, | 505 base::Bind(&GDataURLRequestJob::OnGetEntryInfoByResourceId, |
| 506 weak_ptr_factory_->GetWeakPtr(), | 506 weak_ptr_factory_->GetWeakPtr(), |
| 507 resource_id)); | 507 resource_id)); |
| 508 } | 508 } |
| 509 | 509 |
| 510 void GDataURLRequestJob::OnGetEntryInfoByResourceId( | 510 void GDataURLRequestJob::OnGetEntryInfoByResourceId( |
| 511 const std::string& resource_id, | 511 const std::string& resource_id, |
| 512 GDataFileError error, | 512 GDataFileError error, |
| 513 const FilePath& gdata_file_path, | 513 const FilePath& gdata_file_path, |
| 514 scoped_ptr<GDataEntryProto> entry_proto) { | 514 scoped_ptr<DriveEntryProto> entry_proto) { |
| 515 if (entry_proto.get() && !entry_proto->has_file_specific_info()) | 515 if (entry_proto.get() && !entry_proto->has_file_specific_info()) |
| 516 error = GDATA_FILE_ERROR_NOT_FOUND; | 516 error = GDATA_FILE_ERROR_NOT_FOUND; |
| 517 | 517 |
| 518 if (error == GDATA_FILE_OK) { | 518 if (error == GDATA_FILE_OK) { |
| 519 DCHECK(entry_proto.get()); | 519 DCHECK(entry_proto.get()); |
| 520 mime_type_ = entry_proto->file_specific_info().content_mime_type(); | 520 mime_type_ = entry_proto->file_specific_info().content_mime_type(); |
| 521 gdata_file_path_ = gdata_file_path; | 521 gdata_file_path_ = gdata_file_path; |
| 522 initial_file_size_ = entry_proto->file_info().size(); | 522 initial_file_size_ = entry_proto->file_info().size(); |
| 523 } else { | 523 } else { |
| 524 mime_type_.clear(); | 524 mime_type_.clear(); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 GDataProtocolHandler::~GDataProtocolHandler() { | 934 GDataProtocolHandler::~GDataProtocolHandler() { |
| 935 } | 935 } |
| 936 | 936 |
| 937 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob( | 937 net::URLRequestJob* GDataProtocolHandler::MaybeCreateJob( |
| 938 net::URLRequest* request) const { | 938 net::URLRequest* request) const { |
| 939 DVLOG(1) << "Handling url: " << request->url().spec(); | 939 DVLOG(1) << "Handling url: " << request->url().spec(); |
| 940 return new GDataURLRequestJob(request); | 940 return new GDataURLRequestJob(request); |
| 941 } | 941 } |
| 942 | 942 |
| 943 } // namespace gdata | 943 } // namespace gdata |
| OLD | NEW |