summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 09:40:27 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 09:40:27 +0000
commit77da1199b2bc47f750545b3e49abe96754d30e27 (patch)
treeb2dc4d08174ca142bc8ef8191a00403ec626518b
parentdce6ab4f3586ded2ec236df3942cd021c75644b3 (diff)
downloadchromium_src-77da1199b2bc47f750545b3e49abe96754d30e27.zip
chromium_src-77da1199b2bc47f750545b3e49abe96754d30e27.tar.gz
chromium_src-77da1199b2bc47f750545b3e49abe96754d30e27.tar.bz2
Pass calls to GetApplicationInfo through the scheduler
BUG=160904 Review URL: https://chromiumcodereview.appspot.com/11280140 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170913 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/drive_feed_loader.cc2
-rw-r--r--chrome/browser/chromeos/drive/drive_scheduler.cc21
-rw-r--r--chrome/browser/chromeos/drive/drive_scheduler.h17
-rw-r--r--chrome/browser/chromeos/drive/drive_scheduler_unittest.cc27
4 files changed, 63 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/drive/drive_feed_loader.cc b/chrome/browser/chromeos/drive/drive_feed_loader.cc
index c1ce544..cca69b4 100644
--- a/chrome/browser/chromeos/drive/drive_feed_loader.cc
+++ b/chrome/browser/chromeos/drive/drive_feed_loader.cc
@@ -300,7 +300,7 @@ void DriveFeedLoader::ReloadFromServerIfNeeded(
// Drive v2 needs a separate application list fetch operation.
// TODO(haruki): Application list rarely changes and is not necessarily
// refreshed as often as files.
- drive_service_->GetApplicationInfo(
+ scheduler_->GetApplicationInfo(
base::Bind(&DriveFeedLoader::OnGetApplicationList,
weak_ptr_factory_.GetWeakPtr()));
}
diff --git a/chrome/browser/chromeos/drive/drive_scheduler.cc b/chrome/browser/chromeos/drive/drive_scheduler.cc
index aa91c18..aece264 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler.cc
+++ b/chrome/browser/chromeos/drive/drive_scheduler.cc
@@ -76,6 +76,19 @@ void DriveScheduler::Initialize() {
initialized_ = true;
}
+void DriveScheduler::GetApplicationInfo(
+ const google_apis::GetDataCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ scoped_ptr<QueueEntry> new_job(
+ new QueueEntry(TYPE_GET_APPLICATION_INFO, FilePath()));
+ new_job->get_data_callback = callback;
+
+ QueueJob(new_job.Pass());
+
+ StartJobLoop();
+}
+
void DriveScheduler::Copy(const FilePath& src_file_path,
const FilePath& dest_file_path,
const FileOperationCallback& callback) {
@@ -233,6 +246,14 @@ void DriveScheduler::DoJobLoop() {
const QueueEntry* queue_entry = job_iter->second.get();
switch (job_info.job_type) {
+ case TYPE_GET_APPLICATION_INFO: {
+ drive_service_->GetApplicationInfo(
+ base::Bind(&DriveScheduler::OnGetDataJobDone,
+ weak_ptr_factory_.GetWeakPtr(),
+ job_id));
+ }
+ break;
+
case TYPE_COPY: {
drive_operations_->Copy(
job_info.file_path,
diff --git a/chrome/browser/chromeos/drive/drive_scheduler.h b/chrome/browser/chromeos/drive/drive_scheduler.h
index 23ca018..5cec186 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler.h
+++ b/chrome/browser/chromeos/drive/drive_scheduler.h
@@ -33,6 +33,7 @@ class DriveScheduler
// Enum representing the type of job.
enum JobType {
+ TYPE_GET_APPLICATION_INFO,
TYPE_COPY,
TYPE_GET_DOCUMENTS,
TYPE_MOVE,
@@ -86,6 +87,9 @@ class DriveScheduler
// other functions.
void Initialize();
+ // Adds a GetApplicationInfo operation to the queue.
+ void GetApplicationInfo(const google_apis::GetDataCallback& callback);
+
// Adds a copy operation to the queue.
void Copy(const FilePath& src_file_path,
const FilePath& dest_file_path,
@@ -135,7 +139,7 @@ class DriveScheduler
JobInfo job_info;
- // Callback for when the operation completes.
+ // Callback for operations that take a FileOperationCallback.
// Used by:
// TYPE_COPY,
// TYPE_MOVE,
@@ -154,17 +158,24 @@ class DriveScheduler
// TYPE_TRANSFER_REMOTE_TO_LOCAL
FilePath dest_file_path;
- // Whether the operation is recursive. Used by:
+ // Whether the operation is recursive.
+ // Used by:
// TYPE_REMOVE
bool is_recursive;
- // Parameters for GetDocuments(). Used by:
+ // Parameters for GetDocuments().
+ // Used by:
// TYPE_GET_DOCUMENTS
GURL feed_url;
int64 start_changestamp;
std::string search_query;
bool shared_with_me;
std::string directory_resource_id;
+
+ // Callback for operations that take a GetDataCallback.
+ // Used by:
+ // TYPE_GET_APPLICATION_INFO
+ // TYPE_GET_DOCUMENTS
google_apis::GetDataCallback get_data_callback;
};
diff --git a/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc b/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc
index 531f349..b8db649 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc
+++ b/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc
@@ -99,6 +99,17 @@ class FakeDriveService : public DriveServiceInterface {
}
virtual void GetApplicationInfo(const GetDataCallback& callback) {
+ // Make some sample data.
+ const FilePath account_metadata =
+ test_util::GetTestFilePath("gdata/account_metadata.json");
+ std::string contents;
+ file_util::ReadFileToString(account_metadata, &contents);
+ scoped_ptr<base::Value> data(base::JSONReader::Read(contents));
+
+ base::MessageLoopProxy::current()->PostTask(FROM_HERE,
+ base::Bind(callback,
+ HTTP_SUCCESS,
+ base::Passed(&data)));
}
virtual void DeleteDocument(const GURL& document_url,
@@ -380,6 +391,22 @@ TEST_F(DriveSchedulerTest, TransferRegularFileFile) {
ASSERT_EQ(DRIVE_FILE_OK, error);
}
+TEST_F(DriveSchedulerTest, GetApplicationInfo) {
+ ConnectToWifi();
+
+ google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+ scoped_ptr<base::Value> value;
+
+ scheduler_->GetApplicationInfo(
+ base::Bind(&google_apis::test_util::CopyResultsFromGetDataCallback,
+ &error,
+ &value));
+ google_apis::test_util::RunBlockingPoolTask();
+
+ ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
+ ASSERT_TRUE(value);
+}
+
TEST_F(DriveSchedulerTest, GetDocuments) {
ConnectToWifi();