summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-24 10:30:29 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-24 10:30:29 +0000
commit62bab79e7716b4abf9ed96660deb75399a9daae8 (patch)
treeeeb4dfba30fdca039e651be09d87af7dbc4e4e77
parent5c259807adb96089537f9b6e8c6d63b8b7d6291d (diff)
downloadchromium_src-62bab79e7716b4abf9ed96660deb75399a9daae8.zip
chromium_src-62bab79e7716b4abf9ed96660deb75399a9daae8.tar.gz
chromium_src-62bab79e7716b4abf9ed96660deb75399a9daae8.tar.bz2
Change data source of chrome:drive-internals to drive::JobListInterface.
- Added some utility function to job_list_interface.h (and renamed to job_list.{h,cc} since now it has some implementation.) - Switches the data source of drive-internals to job_list()->GetJobInfoList() - Along the way, fix JavaScript bug that it didn't properly cleared previous list of events. BUG=234899 TEST=Open chrome:drive-internals and check "in-flight operations" section is properly shown. TBR=thestig@chromium.org Review URL: https://chromiumcodereview.appspot.com/13877022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196109 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/drive_scheduler.h2
-rw-r--r--chrome/browser/chromeos/drive/job_list.cc67
-rw-r--r--chrome/browser/chromeos/drive/job_list.h (renamed from chrome/browser/chromeos/drive/job_list_interface.h)14
-rw-r--r--chrome/browser/resources/chromeos/drive_internals.html7
-rw-r--r--chrome/browser/resources/chromeos/drive_internals.js12
-rw-r--r--chrome/browser/ui/webui/chromeos/drive_internals_ui.cc40
-rw-r--r--chrome/chrome_browser_chromeos.gypi3
7 files changed, 103 insertions, 42 deletions
diff --git a/chrome/browser/chromeos/drive/drive_scheduler.h b/chrome/browser/chromeos/drive/drive_scheduler.h
index 1918840..e75b2ed 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler.h
+++ b/chrome/browser/chromeos/drive/drive_scheduler.h
@@ -12,7 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "chrome/browser/chromeos/drive/drive_file_system_interface.h"
-#include "chrome/browser/chromeos/drive/job_list_interface.h"
+#include "chrome/browser/chromeos/drive/job_list.h"
#include "chrome/browser/google_apis/drive_service_interface.h"
#include "chrome/browser/google_apis/drive_uploader.h"
#include "net/base/network_change_notifier.h"
diff --git a/chrome/browser/chromeos/drive/job_list.cc b/chrome/browser/chromeos/drive/job_list.cc
new file mode 100644
index 0000000..3eda377
--- /dev/null
+++ b/chrome/browser/chromeos/drive/job_list.cc
@@ -0,0 +1,67 @@
+// Copyright 2013 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/drive/job_list.h"
+
+#include "base/logging.h"
+
+namespace drive {
+
+std::string JobTypeToString(JobType type) {
+ switch (type){
+ case TYPE_GET_ABOUT_RESOURCE:
+ return "TYPE_GET_ABOUT_RESOURCE";
+ case TYPE_GET_ACCOUNT_METADATA:
+ return "TYPE_GET_ACCOUNT_METADATA";
+ case TYPE_GET_APP_LIST:
+ return "TYPE_GET_APP_LIST";
+ case TYPE_GET_ALL_RESOURCE_LIST:
+ return "TYPE_GET_ALL_RESOURCE_LIST";
+ case TYPE_GET_RESOURCE_LIST_IN_DIRECTORY:
+ return "TYPE_GET_RESOURCE_LIST_IN_DIRECTORY";
+ case TYPE_SEARCH:
+ return "TYPE_SEARCH";
+ case TYPE_GET_CHANGE_LIST:
+ return "TYPE_GET_CHANGE_LIST";
+ case TYPE_CONTINUE_GET_RESOURCE_LIST:
+ return "TYPE_CONTINUE_GET_RESOURCE_LIST";
+ case TYPE_GET_RESOURCE_ENTRY:
+ return "TYPE_GET_RESOURCE_ENTRY";
+ case TYPE_DELETE_RESOURCE:
+ return "TYPE_DELETE_RESOURCE";
+ case TYPE_COPY_HOSTED_DOCUMENT:
+ return "TYPE_COPY_HOSTED_DOCUMENT";
+ case TYPE_RENAME_RESOURCE:
+ return "TYPE_RENAME_RESOURCE";
+ case TYPE_ADD_RESOURCE_TO_DIRECTORY:
+ return "TYPE_ADD_RESOURCE_TO_DIRECTORY";
+ case TYPE_REMOVE_RESOURCE_FROM_DIRECTORY:
+ return "TYPE_REMOVE_RESOURCE_FROM_DIRECTORY";
+ case TYPE_ADD_NEW_DIRECTORY:
+ return "TYPE_ADD_NEW_DIRECTORY";
+ case TYPE_DOWNLOAD_FILE:
+ return "TYPE_DOWNLOAD_FILE";
+ case TYPE_UPLOAD_NEW_FILE:
+ return "TYPE_UPLOAD_NEW_FILE";
+ case TYPE_UPLOAD_EXISTING_FILE:
+ return "TYPE_UPLOAD_EXISTING_FILE";
+ }
+ NOTREACHED();
+ return "(unknown job type)";
+}
+
+std::string JobStateToString(JobState state) {
+ switch (state) {
+ case STATE_NONE:
+ return "STATE_NONE";
+ case STATE_RUNNING:
+ return "STATE_RUNNING";
+ case STATE_RETRY:
+ return "STATE_RETRY";
+ }
+ NOTREACHED();
+ return "(unknown job state)";
+}
+
+} // namespace drive
diff --git a/chrome/browser/chromeos/drive/job_list_interface.h b/chrome/browser/chromeos/drive/job_list.h
index e93ded1..9805e5d 100644
--- a/chrome/browser/chromeos/drive/job_list_interface.h
+++ b/chrome/browser/chromeos/drive/job_list.h
@@ -2,8 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_INTERFACE_H_
-#define CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_INTERFACE_H_
+#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_H_
+#define CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_H_
+
+#include <string>
#include "base/basictypes.h"
#include "base/files/file_path.h"
@@ -33,6 +35,9 @@ enum JobType {
TYPE_UPLOAD_EXISTING_FILE,
};
+// Returns the string representation of |type|.
+std::string JobTypeToString(JobType type);
+
// Current state of the job.
enum JobState {
// The job is queued, but not yet executed.
@@ -45,6 +50,9 @@ enum JobState {
STATE_RETRY,
};
+// Returns the string representation of |state|.
+std::string JobStateToString(JobState state);
+
// Unique ID assigned to each job.
typedef int32 JobID;
@@ -123,4 +131,4 @@ class JobListInterface {
} // namespace drive
-#endif // CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_INTERFACE_H_
+#endif // CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_H_
diff --git a/chrome/browser/resources/chromeos/drive_internals.html b/chrome/browser/resources/chromeos/drive_internals.html
index 0dccb35..127d9f9 100644
--- a/chrome/browser/resources/chromeos/drive_internals.html
+++ b/chrome/browser/resources/chromeos/drive_internals.html
@@ -76,11 +76,10 @@
<table>
<tbody id='in-flight-operations-contents'>
<tr>
- <th>Operation ID</th>
- <th>Operation Type</th>
+ <th>ID</th>
+ <th>Type</th>
<th>File Path</th>
- <th>Transfer State</th>
- <th>Start Time</th>
+ <th>State</th>
<th>Progress</th>
</tr>
</tbody>
diff --git a/chrome/browser/resources/chromeos/drive_internals.js b/chrome/browser/resources/chromeos/drive_internals.js
index dd0f161..731f916 100644
--- a/chrome/browser/resources/chromeos/drive_internals.js
+++ b/chrome/browser/resources/chromeos/drive_internals.js
@@ -104,9 +104,10 @@ function updateLocalStorageUsage(localStorageSummary) {
function updateInFlightOperations(inFlightOperations) {
var container = $('in-flight-operations-contents');
- // Reset the table.
+ // Reset the table. Remove children in reverse order. Otherwides each
+ // existingNodes[i] changes as a side effect of removeChild.
var existingNodes = container.childNodes;
- for (var i = 0; i < existingNodes.length; i++) {
+ for (var i = existingNodes.length - 1; i >= 0; i--) {
var node = existingNodes[i];
if (node.className == 'in-flight-operation')
container.removeChild(node);
@@ -117,11 +118,10 @@ function updateInFlightOperations(inFlightOperations) {
var operation = inFlightOperations[i];
var tr = document.createElement('tr');
tr.className = 'in-flight-operation';
- tr.appendChild(createElementFromText('td', operation.operation_id));
- tr.appendChild(createElementFromText('td', operation.operation_type));
+ tr.appendChild(createElementFromText('td', operation.id));
+ tr.appendChild(createElementFromText('td', operation.type));
tr.appendChild(createElementFromText('td', operation.file_path));
- tr.appendChild(createElementFromText('td', operation.transfer_state));
- tr.appendChild(createElementFromText('td', operation.start_time));
+ tr.appendChild(createElementFromText('td', operation.state));
var progress = operation.progress_current + '/' + operation.progress_total;
if (operation.progress_total > 0) {
progress += ' (' +
diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
index ca8f920..3cc3a9e 100644
--- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
+++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc
@@ -210,8 +210,7 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler {
void UpdateLocalMetadataSection(
google_apis::DriveServiceInterface* drive_service);
void UpdateDeltaUpdateStatusSection();
- void UpdateInFlightOperationsSection(
- google_apis::DriveServiceInterface* drive_service);
+ void UpdateInFlightOperationsSection(drive::JobListInterface* job_list);
void UpdateGCacheContentsSection();
void UpdateFileSystemContentsSection();
void UpdateLocalStorageUsageSection();
@@ -372,7 +371,7 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) {
UpdateAppListSection(drive_service);
UpdateLocalMetadataSection(drive_service);
UpdateDeltaUpdateStatusSection();
- UpdateInFlightOperationsSection(drive_service);
+ UpdateInFlightOperationsSection(system_service->job_list());
UpdateGCacheContentsSection();
UpdateCacheContentsSection(cache);
UpdateLocalStorageUsageSection();
@@ -534,29 +533,20 @@ void DriveInternalsWebUIHandler::OnGetFilesystemMetadataForDeltaUpdate(
}
void DriveInternalsWebUIHandler::UpdateInFlightOperationsSection(
- google_apis::DriveServiceInterface* drive_service) {
- google_apis::OperationProgressStatusList
- progress_status_list = drive_service->GetProgressStatusList();
+ drive::JobListInterface* job_list) {
+ std::vector<drive::JobInfo> info_list = job_list->GetJobInfoList();
base::ListValue in_flight_operations;
- for (size_t i = 0; i < progress_status_list.size(); ++i) {
- const google_apis::OperationProgressStatus& status =
- progress_status_list[i];
+ for (size_t i = 0; i < info_list.size(); ++i) {
+ const drive::JobInfo& info = info_list[i];
base::DictionaryValue* dict = new DictionaryValue;
- dict->SetInteger("operation_id", status.operation_id);
- dict->SetString(
- "operation_type",
- google_apis::OperationTypeToString(status.operation_type));
- dict->SetString("file_path", status.file_path.AsUTF8Unsafe());
- dict->SetString(
- "transfer_state",
- google_apis::OperationTransferStateToString(status.transfer_state));
- dict->SetString(
- "start_time",
- google_apis::util::FormatTimeAsStringLocaltime(status.start_time));
- dict->SetDouble("progress_current", status.progress_current);
- dict->SetDouble("progress_total", status.progress_total);
+ dict->SetInteger("id", info.job_id);
+ dict->SetString("type", drive::JobTypeToString(info.job_type));
+ dict->SetString("file_path", info.file_path.AsUTF8Unsafe());
+ dict->SetString("state", drive::JobStateToString(info.state));
+ dict->SetDouble("progress_current", info.num_completed_bytes);
+ dict->SetDouble("progress_total", info.num_total_bytes);
in_flight_operations.Append(dict);
}
web_ui()->CallJavascriptFunction("updateInFlightOperations",
@@ -738,11 +728,7 @@ void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) {
if (!system_service)
return;
- google_apis::DriveServiceInterface* drive_service =
- system_service->drive_service();
- DCHECK(drive_service);
-
- UpdateInFlightOperationsSection(drive_service);
+ UpdateInFlightOperationsSection(system_service->job_list());
UpdateEventLogSection(system_service->event_logger());
}
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index e94e32f..dd2bae1 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -269,7 +269,8 @@
'browser/chromeos/drive/file_task_executor.h',
'browser/chromeos/drive/file_write_helper.cc',
'browser/chromeos/drive/file_write_helper.h',
- 'browser/chromeos/drive/job_list_interface.h',
+ 'browser/chromeos/drive/job_list.cc',
+ 'browser/chromeos/drive/job_list.h',
'browser/chromeos/drive/resource_entry_conversion.cc',
'browser/chromeos/drive/resource_entry_conversion.h',
'browser/chromeos/drive/search_metadata.cc',