summaryrefslogtreecommitdiffstats
path: root/chrome/browser/drive
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-07 08:54:45 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-07 08:54:45 +0000
commitf69b4289516a6427b52ca5dd344104c52606e97b (patch)
tree65384af97ab68493ea9ab01a36d94e16654d467c /chrome/browser/drive
parent824f5a4d70917b5e9589dd029a4ab4784f2347d0 (diff)
downloadchromium_src-f69b4289516a6427b52ca5dd344104c52606e97b.zip
chromium_src-f69b4289516a6427b52ca5dd344104c52606e97b.tar.gz
chromium_src-f69b4289516a6427b52ca5dd344104c52606e97b.tar.bz2
Parse Drive API responses all at once in the blocking pool.
Previous implementation did the parsing of string to base::Value on blocking pool, and that of base::Value to specific data types either on UI thread or on yet another post to blocking pool. The previous implementation is slightly inefficient and moreover involves a subtle bug 284244. BUG=284244 Review URL: https://codereview.chromium.org/442193002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288017 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/drive')
-rw-r--r--chrome/browser/drive/drive_api_service.cc15
-rw-r--r--chrome/browser/drive/drive_api_util.cc23
-rw-r--r--chrome/browser/drive/drive_api_util.h6
3 files changed, 11 insertions, 33 deletions
diff --git a/chrome/browser/drive/drive_api_service.cc b/chrome/browser/drive/drive_api_service.cc
index 48104ae..7fcb570 100644
--- a/chrome/browser/drive/drive_api_service.cc
+++ b/chrome/browser/drive/drive_api_service.cc
@@ -8,10 +8,7 @@
#include <vector>
#include "base/bind.h"
-#include "base/sequenced_task_runner.h"
#include "base/strings/stringprintf.h"
-#include "base/task_runner_util.h"
-#include "base/values.h"
#include "chrome/browser/drive/drive_api_util.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/drive/auth_service.h"
@@ -147,6 +144,16 @@ void ExtractOpenUrlAndRun(const std::string& app_id,
callback.Run(GDATA_OTHER_ERROR, GURL());
}
+void ExtractShareUrlAndRun(const google_apis::GetShareUrlCallback& callback,
+ google_apis::GDataErrorCode error,
+ scoped_ptr<google_apis::ResourceEntry> entry) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+
+ const google_apis::Link* share_link =
+ entry ? entry->GetLinkByType(google_apis::Link::LINK_SHARE) : NULL;
+ callback.Run(error, share_link ? share_link->href() : GURL());
+}
+
// Ignores the |entry|, and runs the |callback|.
void EntryActionCallbackAdapter(
const EntryActionCallback& callback,
@@ -372,7 +379,7 @@ CancelCallback DriveAPIService::GetShareUrl(
wapi_url_generator_,
resource_id,
embed_origin,
- base::Bind(&util::ParseShareUrlAndRun,
+ base::Bind(&ExtractShareUrlAndRun,
callback)));
}
diff --git a/chrome/browser/drive/drive_api_util.cc b/chrome/browser/drive/drive_api_util.cc
index 1c0d2be..9359c37 100644
--- a/chrome/browser/drive/drive_api_util.cc
+++ b/chrome/browser/drive/drive_api_util.cc
@@ -139,29 +139,6 @@ std::string CanonicalizeResourceId(const std::string& resource_id) {
const char kDocsListScope[] = "https://docs.google.com/feeds/";
const char kDriveAppsScope[] = "https://www.googleapis.com/auth/drive.apps";
-void ParseShareUrlAndRun(const google_apis::GetShareUrlCallback& callback,
- google_apis::GDataErrorCode error,
- scoped_ptr<base::Value> value) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
-
- if (!value) {
- callback.Run(error, GURL());
- return;
- }
-
- // Parsing ResourceEntry is cheap enough to do on UI thread.
- scoped_ptr<google_apis::ResourceEntry> entry =
- google_apis::ResourceEntry::ExtractAndParse(*value);
- if (!entry) {
- callback.Run(google_apis::GDATA_PARSE_ERROR, GURL());
- return;
- }
-
- const google_apis::Link* share_link =
- entry->GetLinkByType(google_apis::Link::LINK_SHARE);
- callback.Run(error, share_link ? share_link->href() : GURL());
-}
-
scoped_ptr<google_apis::ResourceEntry>
ConvertFileResourceToResourceEntry(
const google_apis::FileResource& file_resource) {
diff --git a/chrome/browser/drive/drive_api_util.h b/chrome/browser/drive/drive_api_util.h
index 291e588..90f8820 100644
--- a/chrome/browser/drive/drive_api_util.h
+++ b/chrome/browser/drive/drive_api_util.h
@@ -77,12 +77,6 @@ std::string CanonicalizeResourceId(const std::string& resource_id);
extern const char kDocsListScope[];
extern const char kDriveAppsScope[];
-// Extracts an url to the sharing dialog and returns it via |callback|. If
-// the share url doesn't exist, then an empty url is returned.
-void ParseShareUrlAndRun(const google_apis::GetShareUrlCallback& callback,
- google_apis::GDataErrorCode error,
- scoped_ptr<base::Value> value);
-
// Converts FileResource to ResourceEntry.
scoped_ptr<google_apis::ResourceEntry>
ConvertFileResourceToResourceEntry(