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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api.cc

Issue 2846413002: Switch SupportsUserData uses to use unique_ptr. (Closed)
Patch Set: Created 3 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 | « no previous file | chrome/browser/extensions/api/tab_capture/offscreen_tab.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/api/downloads/downloads_api.h" 5 #include "chrome/browser/extensions/api/downloads/downloads_api.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 explicit ExtensionDownloadsEventRouterData( 613 explicit ExtensionDownloadsEventRouterData(
614 DownloadItem* download_item, 614 DownloadItem* download_item,
615 std::unique_ptr<base::DictionaryValue> json_item) 615 std::unique_ptr<base::DictionaryValue> json_item)
616 : updated_(0), 616 : updated_(0),
617 changed_fired_(0), 617 changed_fired_(0),
618 json_(std::move(json_item)), 618 json_(std::move(json_item)),
619 creator_conflict_action_(downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY), 619 creator_conflict_action_(downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY),
620 determined_conflict_action_( 620 determined_conflict_action_(
621 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY) { 621 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY) {
622 DCHECK_CURRENTLY_ON(BrowserThread::UI); 622 DCHECK_CURRENTLY_ON(BrowserThread::UI);
623 download_item->SetUserData(kKey, this); 623 download_item->SetUserData(kKey, base::WrapUnique(this));
624 } 624 }
625 625
626 ~ExtensionDownloadsEventRouterData() override { 626 ~ExtensionDownloadsEventRouterData() override {
627 if (updated_ > 0) { 627 if (updated_ > 0) {
628 UMA_HISTOGRAM_PERCENTAGE("Download.OnChanged", 628 UMA_HISTOGRAM_PERCENTAGE("Download.OnChanged",
629 (changed_fired_ * 100 / updated_)); 629 (changed_fired_ * 100 / updated_));
630 } 630 }
631 } 631 }
632 632
633 const base::DictionaryValue& json() const { return *json_; } 633 const base::DictionaryValue& json() const { return *json_; }
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 return (data == NULL) ? NULL : 947 return (data == NULL) ? NULL :
948 static_cast<DownloadedByExtension*>(data); 948 static_cast<DownloadedByExtension*>(data);
949 } 949 }
950 950
951 DownloadedByExtension::DownloadedByExtension( 951 DownloadedByExtension::DownloadedByExtension(
952 content::DownloadItem* item, 952 content::DownloadItem* item,
953 const std::string& id, 953 const std::string& id,
954 const std::string& name) 954 const std::string& name)
955 : id_(id), 955 : id_(id),
956 name_(name) { 956 name_(name) {
957 item->SetUserData(kKey, this); 957 item->SetUserData(kKey, base::WrapUnique(this));
958 } 958 }
959 959
960 DownloadsDownloadFunction::DownloadsDownloadFunction() {} 960 DownloadsDownloadFunction::DownloadsDownloadFunction() {}
961 961
962 DownloadsDownloadFunction::~DownloadsDownloadFunction() {} 962 DownloadsDownloadFunction::~DownloadsDownloadFunction() {}
963 963
964 bool DownloadsDownloadFunction::RunAsync() { 964 bool DownloadsDownloadFunction::RunAsync() {
965 std::unique_ptr<downloads::Download::Params> params( 965 std::unique_ptr<downloads::Download::Params> params(
966 downloads::Download::Params::Create(*args_)); 966 downloads::Download::Params::Create(*args_));
967 EXTENSION_FUNCTION_VALIDATE(params.get()); 967 EXTENSION_FUNCTION_VALIDATE(params.get());
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 return; 1923 return;
1924 base::Time now(base::Time::Now()); 1924 base::Time now(base::Time::Now());
1925 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT(); 1925 int delta = now.ToTimeT() - last_checked_removal_.ToTimeT();
1926 if (delta <= kFileExistenceRateLimitSeconds) 1926 if (delta <= kFileExistenceRateLimitSeconds)
1927 return; 1927 return;
1928 last_checked_removal_ = now; 1928 last_checked_removal_ = now;
1929 manager->CheckForHistoryFilesRemoval(); 1929 manager->CheckForHistoryFilesRemoval();
1930 } 1930 }
1931 1931
1932 } // namespace extensions 1932 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tab_capture/offscreen_tab.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698