Index: chrome/browser/ui/webui/chromeos/drive_internals_ui.cc |
diff --git a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc |
index 371f697527123307bab4e46e1467d8f7d5c8d167..dbdcee445af634bc69de91adf368b8e9d92dbc77 100644 |
--- a/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc |
+++ b/chrome/browser/ui/webui/chromeos/drive_internals_ui.cc |
@@ -18,6 +18,7 @@ |
#include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
#include "chrome/browser/chromeos/drive/drive_resource_metadata.h" |
#include "chrome/browser/chromeos/drive/drive_system_service.h" |
+#include "chrome/browser/chromeos/drive/event_logger.h" |
#include "chrome/browser/google_apis/auth_service.h" |
#include "chrome/browser/google_apis/drive_api_parser.h" |
#include "chrome/browser/google_apis/drive_service_interface.h" |
@@ -169,6 +170,7 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { |
public: |
DriveInternalsWebUIHandler() |
: num_pending_reads_(0), |
+ last_sent_event_(""), |
weak_ptr_factory_(this) { |
} |
@@ -202,6 +204,7 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { |
google_apis::DriveServiceInterface* drive_service); |
void UpdateLocalStorageUsageSection(); |
void UpdateCacheContentsSection(drive::DriveCache* cache); |
+ void UpdateEventLogSection(drive::EventLogger* event_logger); |
// Called when GetGCacheContents() is complete. |
void OnGetGCacheContents(base::ListValue* gcache_contents, |
@@ -234,6 +237,9 @@ class DriveInternalsWebUIHandler : public content::WebUIMessageHandler { |
// The number of pending ReadDirectoryByPath() calls. |
int num_pending_reads_; |
+ // The last event sent to the JavaScript side. |
+ drive::EventLogger::Event last_sent_event_; |
+ |
base::WeakPtrFactory<DriveInternalsWebUIHandler> weak_ptr_factory_; |
DISALLOW_COPY_AND_ASSIGN(DriveInternalsWebUIHandler); |
}; |
@@ -330,6 +336,7 @@ void DriveInternalsWebUIHandler::OnPageLoaded(const base::ListValue* args) { |
UpdateFileSystemContentsSection(drive_service); |
UpdateCacheContentsSection(cache); |
UpdateLocalStorageUsageSection(); |
+ UpdateEventLogSection(system_service->event_logger()); |
} |
void DriveInternalsWebUIHandler::UpdateDriveRelatedFlagsSection() { |
@@ -535,6 +542,34 @@ void DriveInternalsWebUIHandler::UpdateCacheContentsSection( |
base::Bind(&base::DoNothing)); |
} |
+void DriveInternalsWebUIHandler::UpdateEventLogSection( |
+ drive::EventLogger* event_logger) { |
+ const std::deque<drive::EventLogger::Event>& log = |
+ event_logger->history(); |
+ |
+ size_t start = 0; |
+ for (size_t i = 0; i < log.size(); ++i) { |
+ if (log[i].when == last_sent_event_.when && |
+ log[i].what == last_sent_event_.what) { |
satorux1
2012/11/14 05:55:11
This looks tricky. What about introducing a monoto
kinaba
2012/11/14 06:19:52
Done.
|
+ start = i+1; |
+ break; |
+ } |
+ } |
+ |
+ if (start < log.size()) { |
+ base::ListValue list; |
+ for (size_t i = start; i < log.size(); ++i) { |
+ base::DictionaryValue* dict = new DictionaryValue; |
+ dict->SetString("key", |
+ google_apis::util::FormatTimeAsStringLocaltime(log[i].when)); |
+ dict->SetString("value", log[i].what); |
+ list.Append(dict); |
+ } |
+ last_sent_event_ = log.back(); |
+ web_ui()->CallJavascriptFunction("updateEventLog", list); |
+ } |
+} |
+ |
void DriveInternalsWebUIHandler::OnGetGCacheContents( |
base::ListValue* gcache_contents, |
base::DictionaryValue* gcache_summary) { |
@@ -630,6 +665,7 @@ void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) { |
DCHECK(drive_service); |
UpdateInFlightOperationsSection(drive_service); |
+ UpdateEventLogSection(system_service->event_logger()); |
} |
} // namespace |