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

Side by Side Diff: chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.cc

Issue 2262423002: Use a vector of smart pointers for callback return type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 4 years, 3 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
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/offline_internals_ui_message_handler.h " 5 #include "chrome/browser/ui/webui/offline/offline_internals_ui_message_handler.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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 offline_page->SetDouble("lastAccessTime", page.last_access_time.ToJsTime()); 111 offline_page->SetDouble("lastAccessTime", page.last_access_time.ToJsTime());
112 offline_page->SetInteger("accessCount", page.access_count); 112 offline_page->SetInteger("accessCount", page.access_count);
113 offline_page->SetString("isExpired", page.IsExpired() ? "Yes" : "No"); 113 offline_page->SetString("isExpired", page.IsExpired() ? "Yes" : "No");
114 } 114 }
115 ResolveJavascriptCallback(base::StringValue(callback_id), results); 115 ResolveJavascriptCallback(base::StringValue(callback_id), results);
116 } 116 }
117 117
118 void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback( 118 void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback(
119 std::string callback_id, 119 std::string callback_id,
120 offline_pages::RequestQueue::GetRequestsResult result, 120 offline_pages::RequestQueue::GetRequestsResult result,
121 const std::vector<offline_pages::SavePageRequest>& requests) { 121 std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests) {
122 base::ListValue save_page_requests; 122 base::ListValue save_page_requests;
123 if (result == offline_pages::RequestQueue::GetRequestsResult::SUCCESS) { 123 if (result == offline_pages::RequestQueue::GetRequestsResult::SUCCESS) {
124 for (const auto& request : requests) { 124 for (const auto& request : requests) {
125 base::DictionaryValue* save_page_request = new base::DictionaryValue(); 125 base::DictionaryValue* save_page_request = new base::DictionaryValue();
126 save_page_requests.Append(save_page_request); 126 save_page_requests.Append(save_page_request);
127 save_page_request->SetString("onlineUrl", request.url().spec()); 127 save_page_request->SetString("onlineUrl", request->url().spec());
128 save_page_request->SetDouble("creationTime", 128 save_page_request->SetDouble("creationTime",
129 request.creation_time().ToJsTime()); 129 request->creation_time().ToJsTime());
130 save_page_request->SetString("status", GetStringFromSavePageStatus()); 130 save_page_request->SetString("status", GetStringFromSavePageStatus());
131 save_page_request->SetString("namespace", request.client_id().name_space); 131 save_page_request->SetString("namespace",
132 request->client_id().name_space);
132 save_page_request->SetDouble("lastAttempt", 133 save_page_request->SetDouble("lastAttempt",
133 request.last_attempt_time().ToJsTime()); 134 request->last_attempt_time().ToJsTime());
134 save_page_request->SetString("id", std::to_string(request.request_id())); 135 save_page_request->SetString("id", std::to_string(request->request_id()));
135 } 136 }
136 } 137 }
137 ResolveJavascriptCallback(base::StringValue(callback_id), save_page_requests); 138 ResolveJavascriptCallback(base::StringValue(callback_id), save_page_requests);
138 } 139 }
139 140
140 void OfflineInternalsUIMessageHandler::HandleGetRequestQueue( 141 void OfflineInternalsUIMessageHandler::HandleGetRequestQueue(
141 const base::ListValue* args) { 142 const base::ListValue* args) {
142 AllowJavascript(); 143 AllowJavascript();
143 std::string callback_id; 144 std::string callback_id;
144 CHECK(args->GetString(0, &callback_id)); 145 CHECK(args->GetString(0, &callback_id));
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 303
303 // Get the offline page model associated with this web ui. 304 // Get the offline page model associated with this web ui.
304 Profile* profile = Profile::FromWebUI(web_ui()); 305 Profile* profile = Profile::FromWebUI(web_ui());
305 offline_page_model_ = 306 offline_page_model_ =
306 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); 307 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile);
307 request_coordinator_ = 308 request_coordinator_ =
308 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); 309 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile);
309 } 310 }
310 311
311 } // namespace offline_internals 312 } // namespace offline_internals
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698