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

Unified Diff: chrome/browser/ui/webui/offline_internals_ui.cc

Issue 2089423002: [Offline Pages] Connect the offline page logs to the internals page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@i4
Patch Set: remove unneeded consts Created 4 years, 6 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
« no previous file with comments | « chrome/browser/resources/offline_pages/offline_internals_browser_proxy.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/offline_internals_ui.cc
diff --git a/chrome/browser/ui/webui/offline_internals_ui.cc b/chrome/browser/ui/webui/offline_internals_ui.cc
index d992c0de130f303b66610b9eef430677684fb2f9..8968b824d3ca9333d3d22cd2e38837386cc4cb42 100644
--- a/chrome/browser/ui/webui/offline_internals_ui.cc
+++ b/chrome/browser/ui/webui/offline_internals_ui.cc
@@ -50,6 +50,18 @@ class OfflineInternalsUIMessageHandler : public content::WebUIMessageHandler {
// Load Stored pages info.
void HandleGetStoredPages(const base::ListValue* args);
+ // Set whether to record offline page model events.
+ void HandleSetRecordPageModel(const base::ListValue* args);
+
+ // Set whether to record request queue events.
+ void HandleSetRecordRequestQueue(const base::ListValue* args);
+
+ // Load both Page Model and Request Queue event logs.
+ void HandleGetEventLogs(const base::ListValue* args);
+
+ // Load whether logs are being recorded.
+ void HandleGetLoggingState(const base::ListValue* args);
+
// Callback for async GetAllPages calls.
void HandleStoredPagesCallback(
std::string callback_id,
@@ -250,6 +262,51 @@ void OfflineInternalsUIMessageHandler::HandleGetStoredPages(
}
}
+void OfflineInternalsUIMessageHandler::HandleSetRecordPageModel(
+ const base::ListValue* args) {
+ bool should_record;
+ CHECK(args->GetBoolean(0, &should_record));
+ offline_page_model_->GetLogger()->SetIsLogging(should_record);
+}
+
+void OfflineInternalsUIMessageHandler::HandleSetRecordRequestQueue(
+ const base::ListValue* args) {
+ bool should_record;
+ CHECK(args->GetBoolean(0, &should_record));
+ request_coordinator_->GetLogger()->SetIsLogging(should_record);
+}
+
+void OfflineInternalsUIMessageHandler::HandleGetLoggingState(
+ const base::ListValue* args) {
+ AllowJavascript();
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+
+ base::DictionaryValue result;
+ result.SetBoolean("modelIsLogging",
+ offline_page_model_->GetLogger()->GetIsLogging());
+ result.SetBoolean("queueIsLogging",
+ request_coordinator_->GetLogger()->GetIsLogging());
+ ResolveJavascriptCallback(*callback_id, result);
+}
+
+void OfflineInternalsUIMessageHandler::HandleGetEventLogs(
+ const base::ListValue* args) {
+ AllowJavascript();
+ const base::Value* callback_id;
+ CHECK(args->Get(0, &callback_id));
+
+ std::vector<std::string> logs;
+ offline_page_model_->GetLogger()->GetLogs(&logs);
+ request_coordinator_->GetLogger()->GetLogs(&logs);
+ std::sort(logs.begin(), logs.end());
+
+ base::ListValue result;
+ result.AppendStrings(logs);
+
+ ResolveJavascriptCallback(*callback_id, result);
+}
+
void OfflineInternalsUIMessageHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"deleteAllPages",
@@ -267,6 +324,22 @@ void OfflineInternalsUIMessageHandler::RegisterMessages() {
"getStoredPages",
base::Bind(&OfflineInternalsUIMessageHandler::HandleGetStoredPages,
weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "getEventLogs",
+ base::Bind(&OfflineInternalsUIMessageHandler::HandleGetEventLogs,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "setRecordRequestQueue",
+ base::Bind(&OfflineInternalsUIMessageHandler::HandleSetRecordRequestQueue,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "setRecordPageModel",
+ base::Bind(&OfflineInternalsUIMessageHandler::HandleSetRecordPageModel,
+ weak_ptr_factory_.GetWeakPtr()));
+ web_ui()->RegisterMessageCallback(
+ "getLoggingState",
+ base::Bind(&OfflineInternalsUIMessageHandler::HandleGetLoggingState,
+ weak_ptr_factory_.GetWeakPtr()));
// Get the offline page model associated with this web ui.
Profile* profile = Profile::FromWebUI(web_ui());
« no previous file with comments | « chrome/browser/resources/offline_pages/offline_internals_browser_proxy.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698