| 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..423a5a4a6b73375ff7c0cc86e9539d025428b835 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_id_(-1),
|
| 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.
|
| + int last_sent_event_id_;
|
| +
|
| 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,28 @@ void DriveInternalsWebUIHandler::UpdateCacheContentsSection(
|
| base::Bind(&base::DoNothing));
|
| }
|
|
|
| +void DriveInternalsWebUIHandler::UpdateEventLogSection(
|
| + drive::EventLogger* event_logger) {
|
| + const std::deque<drive::EventLogger::Event>& log =
|
| + event_logger->history();
|
| +
|
| + base::ListValue list;
|
| + for (size_t i = 0; i < log.size(); ++i) {
|
| + // Skip events which were already sent.
|
| + if (log[i].id <= last_sent_event_id_)
|
| + continue;
|
| +
|
| + 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_id_ = log[i].id;
|
| + }
|
| + if (!list.empty())
|
| + web_ui()->CallJavascriptFunction("updateEventLog", list);
|
| +}
|
| +
|
| void DriveInternalsWebUIHandler::OnGetGCacheContents(
|
| base::ListValue* gcache_contents,
|
| base::DictionaryValue* gcache_summary) {
|
| @@ -630,6 +659,7 @@ void DriveInternalsWebUIHandler::OnPeriodicUpdate(const base::ListValue* args) {
|
| DCHECK(drive_service);
|
|
|
| UpdateInFlightOperationsSection(drive_service);
|
| + UpdateEventLogSection(system_service->event_logger());
|
| }
|
|
|
| } // namespace
|
|
|