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

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

Issue 2811253004: Remove ListValue::Append(raw ptr) on Android (Closed)
Patch Set: Add includes Created 3 years, 8 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 <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/guid.h" 13 #include "base/guid.h"
14 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
jdoerrie 2017/04/12 16:08:55 #include "base/values.h"
vabr (Chromium) 2017/04/12 16:40:52 Done.
14 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" 16 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
15 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h" 17 #include "chrome/browser/android/offline_pages/request_coordinator_factory.h"
16 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
17 #include "components/offline_pages/core/client_namespace_constants.h" 19 #include "components/offline_pages/core/client_namespace_constants.h"
18 #include "content/public/browser/web_ui.h" 20 #include "content/public/browser/web_ui.h"
19 #include "net/base/network_change_notifier.h" 21 #include "net/base/network_change_notifier.h"
20 22
21 namespace offline_internals { 23 namespace offline_internals {
22 24
23 OfflineInternalsUIMessageHandler::OfflineInternalsUIMessageHandler() 25 OfflineInternalsUIMessageHandler::OfflineInternalsUIMessageHandler()
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 base::Value(callback_id), 128 base::Value(callback_id),
127 base::Value(GetStringFromDeleteRequestResults(results))); 129 base::Value(GetStringFromDeleteRequestResults(results)));
128 } 130 }
129 131
130 void OfflineInternalsUIMessageHandler::HandleStoredPagesCallback( 132 void OfflineInternalsUIMessageHandler::HandleStoredPagesCallback(
131 std::string callback_id, 133 std::string callback_id,
132 const offline_pages::MultipleOfflinePageItemResult& pages) { 134 const offline_pages::MultipleOfflinePageItemResult& pages) {
133 base::ListValue results; 135 base::ListValue results;
134 136
135 for (const auto& page : pages) { 137 for (const auto& page : pages) {
136 base::DictionaryValue* offline_page = new base::DictionaryValue(); 138 auto offline_page = base::MakeUnique<base::DictionaryValue>();
137 results.Append(offline_page); 139 results.Append(std::move(offline_page));
jdoerrie 2017/04/12 16:08:55 This moves out of offline_page. Move this line to
vabr (Chromium) 2017/04/12 16:40:52 Oops, thanks for catching!
138 offline_page->SetString("onlineUrl", page.url.spec()); 140 offline_page->SetString("onlineUrl", page.url.spec());
139 offline_page->SetString("namespace", page.client_id.name_space); 141 offline_page->SetString("namespace", page.client_id.name_space);
140 offline_page->SetDouble("size", page.file_size); 142 offline_page->SetDouble("size", page.file_size);
141 offline_page->SetString("id", std::to_string(page.offline_id)); 143 offline_page->SetString("id", std::to_string(page.offline_id));
142 offline_page->SetString("filePath", page.file_path.MaybeAsASCII()); 144 offline_page->SetString("filePath", page.file_path.MaybeAsASCII());
143 offline_page->SetDouble("creationTime", page.creation_time.ToJsTime()); 145 offline_page->SetDouble("creationTime", page.creation_time.ToJsTime());
144 offline_page->SetDouble("lastAccessTime", page.last_access_time.ToJsTime()); 146 offline_page->SetDouble("lastAccessTime", page.last_access_time.ToJsTime());
145 offline_page->SetInteger("accessCount", page.access_count); 147 offline_page->SetInteger("accessCount", page.access_count);
146 offline_page->SetString("originalUrl", page.original_url.spec()); 148 offline_page->SetString("originalUrl", page.original_url.spec());
147 } 149 }
148 ResolveJavascriptCallback(base::Value(callback_id), results); 150 ResolveJavascriptCallback(base::Value(callback_id), results);
149 } 151 }
150 152
151 void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback( 153 void OfflineInternalsUIMessageHandler::HandleRequestQueueCallback(
152 std::string callback_id, 154 std::string callback_id,
153 offline_pages::GetRequestsResult result, 155 offline_pages::GetRequestsResult result,
154 std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests) { 156 std::vector<std::unique_ptr<offline_pages::SavePageRequest>> requests) {
155 base::ListValue save_page_requests; 157 base::ListValue save_page_requests;
156 if (result == offline_pages::GetRequestsResult::SUCCESS) { 158 if (result == offline_pages::GetRequestsResult::SUCCESS) {
157 for (const auto& request : requests) { 159 for (const auto& request : requests) {
158 base::DictionaryValue* save_page_request = new base::DictionaryValue(); 160 auto save_page_request = base::MakeUnique<base::DictionaryValue>();
159 save_page_requests.Append(save_page_request); 161 save_page_requests.Append(std::move(save_page_request));
jdoerrie 2017/04/12 16:08:55 Same here. I am surprised I didn't hit this code d
vabr (Chromium) 2017/04/12 16:40:52 I guess that's either lack of test coverage in thi
160 save_page_request->SetString("onlineUrl", request->url().spec()); 162 save_page_request->SetString("onlineUrl", request->url().spec());
161 save_page_request->SetDouble("creationTime", 163 save_page_request->SetDouble("creationTime",
162 request->creation_time().ToJsTime()); 164 request->creation_time().ToJsTime());
163 save_page_request->SetString("status", GetStringFromSavePageStatus()); 165 save_page_request->SetString("status", GetStringFromSavePageStatus());
164 save_page_request->SetString("namespace", 166 save_page_request->SetString("namespace",
165 request->client_id().name_space); 167 request->client_id().name_space);
166 save_page_request->SetDouble("lastAttempt", 168 save_page_request->SetDouble("lastAttempt",
167 request->last_attempt_time().ToJsTime()); 169 request->last_attempt_time().ToJsTime());
168 save_page_request->SetString("id", std::to_string(request->request_id())); 170 save_page_request->SetString("id", std::to_string(request->request_id()));
169 save_page_request->SetString("originalUrl", 171 save_page_request->SetString("originalUrl",
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 342
341 // Get the offline page model associated with this web ui. 343 // Get the offline page model associated with this web ui.
342 Profile* profile = Profile::FromWebUI(web_ui()); 344 Profile* profile = Profile::FromWebUI(web_ui());
343 offline_page_model_ = 345 offline_page_model_ =
344 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile); 346 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile);
345 request_coordinator_ = 347 request_coordinator_ =
346 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile); 348 offline_pages::RequestCoordinatorFactory::GetForBrowserContext(profile);
347 } 349 }
348 350
349 } // namespace offline_internals 351 } // namespace offline_internals
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698