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

Side by Side Diff: ios/chrome/browser/ui/webui/history/browsing_history_handler.cc

Issue 2000803003: Use std::unique_ptr for base::DictionaryValue and base::ListValue's internal store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More fixes Created 4 years, 7 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 | « extensions/renderer/dispatcher.cc ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('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 "ios/chrome/browser/ui/webui/history/browsing_history_handler.h" 5 #include "ios/chrome/browser/ui/webui/history/browsing_history_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 10
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 ios::HistoryServiceFactory::GetForBrowserState( 449 ios::HistoryServiceFactory::GetForBrowserState(
450 browser_state, ServiceAccessType::EXPLICIT_ACCESS); 450 browser_state, ServiceAccessType::EXPLICIT_ACCESS);
451 history::WebHistoryService* web_history = 451 history::WebHistoryService* web_history =
452 ios::WebHistoryServiceFactory::GetForBrowserState(browser_state); 452 ios::WebHistoryServiceFactory::GetForBrowserState(browser_state);
453 453
454 base::Time now = base::Time::Now(); 454 base::Time now = base::Time::Now();
455 std::vector<history::ExpireHistoryArgs> expire_list; 455 std::vector<history::ExpireHistoryArgs> expire_list;
456 expire_list.reserve(args->GetSize()); 456 expire_list.reserve(args->GetSize());
457 457
458 DCHECK(urls_to_be_deleted_.empty()); 458 DCHECK(urls_to_be_deleted_.empty());
459 for (base::Value* arg : *args) { 459 for (const auto& arg : *args) {
460 base::DictionaryValue* deletion = NULL; 460 base::DictionaryValue* deletion = NULL;
461 base::string16 url; 461 base::string16 url;
462 base::ListValue* timestamps = NULL; 462 base::ListValue* timestamps = NULL;
463 463
464 // Each argument is a dictionary with properties "url" and "timestamps". 464 // Each argument is a dictionary with properties "url" and "timestamps".
465 if (!(arg->GetAsDictionary(&deletion) && deletion->GetString("url", &url) && 465 if (!(arg->GetAsDictionary(&deletion) && deletion->GetString("url", &url) &&
466 deletion->GetList("timestamps", &timestamps))) { 466 deletion->GetList("timestamps", &timestamps))) {
467 NOTREACHED() << "Unable to extract arguments"; 467 NOTREACHED() << "Unable to extract arguments";
468 return; 468 return;
469 } 469 }
470 DCHECK(timestamps->GetSize() > 0); 470 DCHECK(timestamps->GetSize() > 0);
471 471
472 // In order to ensure that visits will be deleted from the server and other 472 // In order to ensure that visits will be deleted from the server and other
473 // clients (even if they are offline), create a sync delete directive for 473 // clients (even if they are offline), create a sync delete directive for
474 // each visit to be deleted. 474 // each visit to be deleted.
475 sync_pb::HistoryDeleteDirectiveSpecifics delete_directive; 475 sync_pb::HistoryDeleteDirectiveSpecifics delete_directive;
476 sync_pb::GlobalIdDirective* global_id_directive = 476 sync_pb::GlobalIdDirective* global_id_directive =
477 delete_directive.mutable_global_id_directive(); 477 delete_directive.mutable_global_id_directive();
478 478
479 double timestamp; 479 double timestamp;
480 history::ExpireHistoryArgs* expire_args = NULL; 480 history::ExpireHistoryArgs* expire_args = NULL;
481 for (base::Value* timestamp_value : *timestamps) { 481 for (const auto& timestamp_value : *timestamps) {
482 if (!timestamp_value->GetAsDouble(&timestamp)) { 482 if (!timestamp_value->GetAsDouble(&timestamp)) {
483 NOTREACHED() << "Unable to extract visit timestamp."; 483 NOTREACHED() << "Unable to extract visit timestamp.";
484 continue; 484 continue;
485 } 485 }
486 base::Time visit_time = base::Time::FromJsTime(timestamp); 486 base::Time visit_time = base::Time::FromJsTime(timestamp);
487 if (!expire_args) { 487 if (!expire_args) {
488 GURL gurl(url); 488 GURL gurl(url);
489 expire_list.resize(expire_list.size() + 1); 489 expire_list.resize(expire_list.size() + 1);
490 expire_args = &expire_list.back(); 490 expire_args = &expire_list.back();
491 expire_args->SetTimeRangeForOneDay(visit_time); 491 expire_args->SetTimeRangeForOneDay(visit_time);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 839
840 void BrowsingHistoryHandler::OnURLsDeleted( 840 void BrowsingHistoryHandler::OnURLsDeleted(
841 history::HistoryService* history_service, 841 history::HistoryService* history_service,
842 bool all_history, 842 bool all_history,
843 bool expired, 843 bool expired,
844 const history::URLRows& deleted_rows, 844 const history::URLRows& deleted_rows,
845 const std::set<GURL>& favicon_urls) { 845 const std::set<GURL>& favicon_urls) {
846 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_)) 846 if (all_history || DeletionsDiffer(deleted_rows, urls_to_be_deleted_))
847 web_ui()->CallJavascriptFunction("historyDeleted"); 847 web_ui()->CallJavascriptFunction("historyDeleted");
848 } 848 }
OLDNEW
« no previous file with comments | « extensions/renderer/dispatcher.cc ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698