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

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

Issue 10829375: Cleanup: separate WAPI and Drive API code in gdata_documents_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gdata/drive_api_service.cc
diff --git a/chrome/browser/chromeos/gdata/drive_api_service.cc b/chrome/browser/chromeos/gdata/drive_api_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..acd653fd31c6b742562c772b3d5311a05b17d23e
--- /dev/null
+++ b/chrome/browser/chromeos/gdata/drive_api_service.cc
@@ -0,0 +1,237 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/gdata/drive_api_service.h"
+
+#include <string>
+
+#include "base/bind.h"
+#include "base/message_loop_proxy.h"
+#include "chrome/browser/chromeos/gdata/drive_api_operations.h"
+#include "chrome/browser/chromeos/gdata/gdata_operation_runner.h"
+#include "chrome/browser/chromeos/gdata/gdata_operations.h"
+#include "chrome/browser/chromeos/gdata/gdata_util.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/net/url_util.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+namespace gdata {
+
+DriveAPIService::DriveAPIService()
+ : profile_(NULL),
+ runner_(NULL) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+}
+
+DriveAPIService::~DriveAPIService() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+}
+
+void DriveAPIService::Initialize(Profile* profile) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ profile_ = profile;
+ runner_.reset(new GDataOperationRunner(profile));
+ runner_->Initialize();
+}
+
+GDataOperationRegistry* DriveAPIService::operation_registry() const {
+ return runner_->operation_registry();
+}
+
+void DriveAPIService::CancelAll() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ runner_->CancelAll();
+}
+
+void DriveAPIService::Authenticate(const AuthStatusCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ runner_->Authenticate(callback);
+}
+
+void DriveAPIService::GetDocuments(const GURL& url,
+ int64 start_changestamp,
+ const std::string& search_query,
+ const std::string& directory_resource_id,
+ const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (search_query.empty())
+ GetChangelist(url, start_changestamp, callback);
+ else
+ GetFilelist(url, search_query, callback);
+
+ return;
+ // TODO(kochi): Implement !directory_resource_id.empty() case.
+ NOTREACHED();
+}
+
+void DriveAPIService::GetFilelist(const GURL& url,
+ const std::string& search_query,
+ const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ runner_->StartOperationWithRetry(
+ new GetFilelistOperation(operation_registry(),
+ url,
+ search_query,
+ callback));
+}
+
+void DriveAPIService::GetChangelist(const GURL& url,
+ int64 start_changestamp,
+ const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ runner_->StartOperationWithRetry(
+ new GetChangelistOperation(operation_registry(),
+ url,
+ start_changestamp,
+ callback));
+}
+
+void DriveAPIService::GetDocumentEntry(const std::string& resource_id,
+ const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ runner_->StartOperationWithRetry(new GetFileOperation(operation_registry(),
+ resource_id,
+ callback));
+}
+
+void DriveAPIService::GetAccountMetadata(const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ runner_->StartOperationWithRetry(
+ new GetAboutOperation(operation_registry(), callback));
+}
+
+void DriveAPIService::GetApplicationInfo(const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ runner_->StartOperationWithRetry(
+ new GetApplistOperation(operation_registry(), callback));
+}
+
+void DriveAPIService::DownloadDocument(
+ const FilePath& virtual_path,
+ const FilePath& local_cache_path,
+ const GURL& document_url,
+ DocumentExportFormat format,
+ const DownloadActionCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::DownloadFile(
+ const FilePath& virtual_path,
+ const FilePath& local_cache_path,
+ const GURL& document_url,
+ const DownloadActionCallback& download_action_callback,
+ const GetContentCallback& get_content_callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::DeleteDocument(const GURL& document_url,
+ const EntryActionCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::CreateDirectory(
+ const GURL& parent_content_url,
+ const FilePath::StringType& directory_name,
+ const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::CopyDocument(const std::string& resource_id,
+ const FilePath::StringType& new_name,
+ const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::RenameResource(const GURL& resource_url,
+ const FilePath::StringType& new_name,
+ const EntryActionCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::AddResourceToDirectory(
+ const GURL& parent_content_url,
+ const GURL& resource_url,
+ const EntryActionCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::RemoveResourceFromDirectory(
+ const GURL& parent_content_url,
+ const GURL& resource_url,
+ const std::string& resource_id,
+ const EntryActionCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::InitiateUpload(const InitiateUploadParams& params,
+ const InitiateUploadCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+void DriveAPIService::ResumeUpload(const ResumeUploadParams& params,
+ const ResumeUploadCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+
+void DriveAPIService::AuthorizeApp(const GURL& resource_url,
+ const std::string& app_ids,
+ const GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kochi): Implement this.
+ NOTREACHED();
+}
+
+bool DriveAPIService::HasAccessToken() const {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ return runner_->auth_service()->HasAccessToken();
+}
+
+bool DriveAPIService::HasRefreshToken() const {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ return runner_->auth_service()->HasRefreshToken();
+}
+
+} // namespace gdata
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_api_service.h ('k') | chrome/browser/chromeos/gdata/drive_task_executor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698