| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |