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

Side by Side Diff: chrome/browser/ui/webui/offline_internals_ui.cc

Issue 2209993002: Remove the GetStatus() call from SavePageRequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Undo the fix for closure since we put status back. Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/offline_pages/background/save_page_request.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/offline_internals_ui.h" 5 #include "chrome/browser/ui/webui/offline_internals_ui.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 // Callback for DeletePage/ClearAll calls. 86 // Callback for DeletePage/ClearAll calls.
87 void HandleDeletedPagesCallback(std::string callback_id, 87 void HandleDeletedPagesCallback(std::string callback_id,
88 const offline_pages::DeletePageResult result); 88 const offline_pages::DeletePageResult result);
89 89
90 // Turns a DeletePageResult enum into logical string. 90 // Turns a DeletePageResult enum into logical string.
91 std::string GetStringFromDeletePageResult( 91 std::string GetStringFromDeletePageResult(
92 offline_pages::DeletePageResult value); 92 offline_pages::DeletePageResult value);
93 93
94 // Turns a SavePageRequest::Status into logical string. 94 // Turns a SavePageRequest::Status into logical string.
95 std::string GetStringFromSavePageStatus( 95 std::string GetStringFromSavePageStatus();
96 offline_pages::SavePageRequest::Status status);
97 96
98 // Offline page model to call methods on. 97 // Offline page model to call methods on.
99 offline_pages::OfflinePageModel* offline_page_model_; 98 offline_pages::OfflinePageModel* offline_page_model_;
100 99
101 // Request coordinator for background offline actions. 100 // Request coordinator for background offline actions.
102 offline_pages::RequestCoordinator* request_coordinator_; 101 offline_pages::RequestCoordinator* request_coordinator_;
103 102
104 // Factory for creating references in callbacks. 103 // Factory for creating references in callbacks.
105 base::WeakPtrFactory<OfflineInternalsUIMessageHandler> weak_ptr_factory_; 104 base::WeakPtrFactory<OfflineInternalsUIMessageHandler> weak_ptr_factory_;
106 105
(...skipping 20 matching lines...) Expand all
127 return "Device failure"; 126 return "Device failure";
128 case offline_pages::DeletePageResult::NOT_FOUND: 127 case offline_pages::DeletePageResult::NOT_FOUND:
129 return "Not found"; 128 return "Not found";
130 case offline_pages::DeletePageResult::RESULT_COUNT: 129 case offline_pages::DeletePageResult::RESULT_COUNT:
131 break; 130 break;
132 } 131 }
133 NOTREACHED(); 132 NOTREACHED();
134 return "Unknown"; 133 return "Unknown";
135 } 134 }
136 135
137 std::string OfflineInternalsUIMessageHandler::GetStringFromSavePageStatus( 136 std::string OfflineInternalsUIMessageHandler::GetStringFromSavePageStatus() {
138 offline_pages::SavePageRequest::Status status) { 137 return "Available";
139 switch (status) {
140 case offline_pages::SavePageRequest::Status::NOT_READY:
141 return "Not ready";
142 case offline_pages::SavePageRequest::Status::PENDING:
143 return "Pending";
144 case offline_pages::SavePageRequest::Status::STARTED:
145 return "Started";
146 case offline_pages::SavePageRequest::Status::FAILED:
147 return "Failed";
148 case offline_pages::SavePageRequest::Status::EXPIRED:
149 return "Expired";
150 }
151 NOTREACHED();
152 return "Unknown";
153 } 138 }
154 139
155 void OfflineInternalsUIMessageHandler::HandleDeleteAllPages( 140 void OfflineInternalsUIMessageHandler::HandleDeleteAllPages(
156 const base::ListValue* args) { 141 const base::ListValue* args) {
157 std::string callback_id; 142 std::string callback_id;
158 CHECK(args->GetString(0, &callback_id)); 143 CHECK(args->GetString(0, &callback_id));
159 144
160 // Pass back success because ClearAll doesn't return a status. 145 // Pass back success because ClearAll doesn't return a status.
161 offline_page_model_->ClearAll( 146 offline_page_model_->ClearAll(
162 base::Bind(&OfflineInternalsUIMessageHandler::HandleDeletedPagesCallback, 147 base::Bind(&OfflineInternalsUIMessageHandler::HandleDeletedPagesCallback,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 base::ListValue save_page_requests; 209 base::ListValue save_page_requests;
225 if (result == offline_pages::RequestQueue::GetRequestsResult::SUCCESS) { 210 if (result == offline_pages::RequestQueue::GetRequestsResult::SUCCESS) {
226 for (const auto& request : requests) { 211 for (const auto& request : requests) {
227 base::DictionaryValue* save_page_request = new base::DictionaryValue(); 212 base::DictionaryValue* save_page_request = new base::DictionaryValue();
228 save_page_requests.Append(save_page_request); 213 save_page_requests.Append(save_page_request);
229 save_page_request->SetString("onlineUrl", request.url().spec()); 214 save_page_request->SetString("onlineUrl", request.url().spec());
230 save_page_request->SetDouble("creationTime", 215 save_page_request->SetDouble("creationTime",
231 request.creation_time().ToJsTime()); 216 request.creation_time().ToJsTime());
232 save_page_request->SetString( 217 save_page_request->SetString(
233 "status", 218 "status",
234 GetStringFromSavePageStatus(request.GetStatus(base::Time::Now()))); 219 GetStringFromSavePageStatus());
235 save_page_request->SetString("namespace", request.client_id().name_space); 220 save_page_request->SetString("namespace", request.client_id().name_space);
236 save_page_request->SetDouble("lastAttempt", 221 save_page_request->SetDouble("lastAttempt",
237 request.last_attempt_time().ToJsTime()); 222 request.last_attempt_time().ToJsTime());
238 save_page_request->SetString("id", std::to_string(request.request_id())); 223 save_page_request->SetString("id", std::to_string(request.request_id()));
239 } 224 }
240 } 225 }
241 ResolveJavascriptCallback(base::StringValue(callback_id), save_page_requests); 226 ResolveJavascriptCallback(base::StringValue(callback_id), save_page_requests);
242 } 227 }
243 228
244 void OfflineInternalsUIMessageHandler::HandleGetRequestQueue( 229 void OfflineInternalsUIMessageHandler::HandleGetRequestQueue(
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 html_source->AddResourcePath("offline_internals_browser_proxy.js", 404 html_source->AddResourcePath("offline_internals_browser_proxy.js",
420 IDR_OFFLINE_INTERNALS_BROWSER_PROXY_JS); 405 IDR_OFFLINE_INTERNALS_BROWSER_PROXY_JS);
421 html_source->SetDefaultResource(IDR_OFFLINE_INTERNALS_HTML); 406 html_source->SetDefaultResource(IDR_OFFLINE_INTERNALS_HTML);
422 407
423 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source); 408 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), html_source);
424 409
425 web_ui->AddMessageHandler(new OfflineInternalsUIMessageHandler()); 410 web_ui->AddMessageHandler(new OfflineInternalsUIMessageHandler());
426 } 411 }
427 412
428 OfflineInternalsUI::~OfflineInternalsUI() {} 413 OfflineInternalsUI::~OfflineInternalsUI() {}
OLDNEW
« no previous file with comments | « no previous file | components/offline_pages/background/save_page_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698