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

Unified Diff: chrome/browser/chromeos/gdata/gdata_protocol_handler.cc

Issue 10538071: gdata: Convert FindEntryByResourceIdSync() to asynchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase svn:trunk/src@141679 and resolve conflicts. Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_params.h ('k') | chrome/browser/chromeos/gdata/gdata_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_protocol_handler.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_protocol_handler.cc b/chrome/browser/chromeos/gdata/gdata_protocol_handler.cc
index ea671cfd385b9239aa43d8d85731843ac0930f9a..e61fbea3d31bca351408d5edbcc70e63852b159b 100644
--- a/chrome/browser/chromeos/gdata/gdata_protocol_handler.cc
+++ b/chrome/browser/chromeos/gdata/gdata_protocol_handler.cc
@@ -149,6 +149,11 @@ class GDataURLRequestJob : public net::URLRequestJob {
// to |file_size|, and notifies result for Start().
void OnGetFileSize(int64 *file_size);
+ // Helper callback for FindEntryByResourceId invoked by StartAsync.
+ void OnFindEntryByResourceId(const std::string& resource_id,
+ base::PlatformFileError error,
+ GDataEntry* entry);
+
// Helper methods for ReadRawData to open file and read from its corresponding
// stream in a streaming fashion.
bool ContinueReadFromFile(int* bytes_read);
@@ -320,22 +325,7 @@ void GDataURLRequestJob::Kill() {
bool GDataURLRequestJob::GetMimeType(std::string* mime_type) const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- if (!file_system_)
- return false;
-
- std::string resource_id;
- std::string unused_file_name;
- if (!ParseDriveUrl(request_->url().spec(), &resource_id)) {
- return false;
- }
-
- GDataEntry* entry = NULL;
- file_system_->FindEntryByResourceIdSync(
- resource_id, base::Bind(&ReadOnlyFindEntryCallback, &entry));
- if (!entry || !entry->AsGDataFile())
- return false;
- mime_type->assign(entry->AsGDataFile()->content_mime_type());
+ mime_type->assign(mime_type_);
return !mime_type->empty();
}
@@ -484,11 +474,18 @@ void GDataURLRequestJob::StartAsync(GDataFileSystem** file_system) {
return;
}
- // First, check if file metadata is matching our expectations.
- GDataEntry* entry = NULL;
- file_system_->FindEntryByResourceIdSync(
- resource_id, base::Bind(&ReadOnlyFindEntryCallback, &entry));
- if (entry && entry->AsGDataFile()) {
+ file_system_->FindEntryByResourceId(
+ resource_id,
+ base::Bind(&GDataURLRequestJob::OnFindEntryByResourceId,
+ weak_ptr_factory_->GetWeakPtr(),
+ resource_id));
+}
+
+void GDataURLRequestJob::OnFindEntryByResourceId(
+ const std::string& resource_id,
+ base::PlatformFileError error,
+ GDataEntry* entry) {
+ if (error == base::PLATFORM_FILE_OK && entry && entry->AsGDataFile()) {
mime_type_ = entry->AsGDataFile()->content_mime_type();
gdata_file_path_ = entry->GetFilePath();
initial_file_size_ = entry->file_info().size;
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_params.h ('k') | chrome/browser/chromeos/gdata/gdata_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698