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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } | 290 } |
291 // TODO(benjhayden): Implement fileSize. | 291 // TODO(benjhayden): Implement fileSize. |
292 json->SetDouble(kFileSizeKey, download_item->GetTotalBytes()); | 292 json->SetDouble(kFileSizeKey, download_item->GetTotalBytes()); |
293 return scoped_ptr<base::DictionaryValue>(json); | 293 return scoped_ptr<base::DictionaryValue>(json); |
294 } | 294 } |
295 | 295 |
296 class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor { | 296 class DownloadFileIconExtractorImpl : public DownloadFileIconExtractor { |
297 public: | 297 public: |
298 DownloadFileIconExtractorImpl() {} | 298 DownloadFileIconExtractorImpl() {} |
299 | 299 |
300 virtual ~DownloadFileIconExtractorImpl() {} | 300 ~DownloadFileIconExtractorImpl() override {} |
301 | 301 |
302 virtual bool ExtractIconURLForPath(const base::FilePath& path, | 302 bool ExtractIconURLForPath(const base::FilePath& path, |
303 float scale, | 303 float scale, |
304 IconLoader::IconSize icon_size, | 304 IconLoader::IconSize icon_size, |
305 IconURLCallback callback) override; | 305 IconURLCallback callback) override; |
| 306 |
306 private: | 307 private: |
307 void OnIconLoadComplete( | 308 void OnIconLoadComplete( |
308 float scale, const IconURLCallback& callback, gfx::Image* icon); | 309 float scale, const IconURLCallback& callback, gfx::Image* icon); |
309 | 310 |
310 base::CancelableTaskTracker cancelable_task_tracker_; | 311 base::CancelableTaskTracker cancelable_task_tracker_; |
311 }; | 312 }; |
312 | 313 |
313 bool DownloadFileIconExtractorImpl::ExtractIconURLForPath( | 314 bool DownloadFileIconExtractorImpl::ExtractIconURLForPath( |
314 const base::FilePath& path, | 315 const base::FilePath& path, |
315 float scale, | 316 float scale, |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 changed_fired_(0), | 593 changed_fired_(0), |
593 json_(json_item.Pass()), | 594 json_(json_item.Pass()), |
594 creator_conflict_action_( | 595 creator_conflict_action_( |
595 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY), | 596 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY), |
596 determined_conflict_action_( | 597 determined_conflict_action_( |
597 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY) { | 598 downloads::FILENAME_CONFLICT_ACTION_UNIQUIFY) { |
598 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 599 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
599 download_item->SetUserData(kKey, this); | 600 download_item->SetUserData(kKey, this); |
600 } | 601 } |
601 | 602 |
602 virtual ~ExtensionDownloadsEventRouterData() { | 603 ~ExtensionDownloadsEventRouterData() override { |
603 if (updated_ > 0) { | 604 if (updated_ > 0) { |
604 UMA_HISTOGRAM_PERCENTAGE("Download.OnChanged", | 605 UMA_HISTOGRAM_PERCENTAGE("Download.OnChanged", |
605 (changed_fired_ * 100 / updated_)); | 606 (changed_fired_ * 100 / updated_)); |
606 } | 607 } |
607 } | 608 } |
608 | 609 |
609 const base::DictionaryValue& json() const { return *json_.get(); } | 610 const base::DictionaryValue& json() const { return *json_.get(); } |
610 void set_json(scoped_ptr<base::DictionaryValue> json_item) { | 611 void set_json(scoped_ptr<base::DictionaryValue> json_item) { |
611 json_ = json_item.Pass(); | 612 json_ = json_item.Pass(); |
612 } | 613 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 } | 883 } |
883 | 884 |
884 private: | 885 private: |
885 static const int kFileExistenceRateLimitSeconds = 10; | 886 static const int kFileExistenceRateLimitSeconds = 10; |
886 | 887 |
887 explicit ManagerDestructionObserver(DownloadManager* manager) | 888 explicit ManagerDestructionObserver(DownloadManager* manager) |
888 : manager_(manager) { | 889 : manager_(manager) { |
889 manager_->AddObserver(this); | 890 manager_->AddObserver(this); |
890 } | 891 } |
891 | 892 |
892 virtual ~ManagerDestructionObserver() { | 893 ~ManagerDestructionObserver() override { manager_->RemoveObserver(this); } |
893 manager_->RemoveObserver(this); | |
894 } | |
895 | 894 |
896 virtual void ManagerGoingDown(DownloadManager* manager) override { | 895 void ManagerGoingDown(DownloadManager* manager) override { |
897 manager_file_existence_last_checked_->erase(manager); | 896 manager_file_existence_last_checked_->erase(manager); |
898 if (manager_file_existence_last_checked_->size() == 0) { | 897 if (manager_file_existence_last_checked_->size() == 0) { |
899 delete manager_file_existence_last_checked_; | 898 delete manager_file_existence_last_checked_; |
900 manager_file_existence_last_checked_ = NULL; | 899 manager_file_existence_last_checked_ = NULL; |
901 } | 900 } |
902 } | 901 } |
903 | 902 |
904 void CheckForHistoryFilesRemovalInternal() { | 903 void CheckForHistoryFilesRemovalInternal() { |
905 base::Time now(base::Time::Now()); | 904 base::Time now(base::Time::Now()); |
906 int delta = now.ToTimeT() - last_checked_.ToTimeT(); | 905 int delta = now.ToTimeT() - last_checked_.ToTimeT(); |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1931 const Extension* extension, | 1930 const Extension* extension, |
1932 UnloadedExtensionInfo::Reason reason) { | 1931 UnloadedExtensionInfo::Reason reason) { |
1933 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1932 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
1934 std::set<const Extension*>::iterator iter = | 1933 std::set<const Extension*>::iterator iter = |
1935 shelf_disabling_extensions_.find(extension); | 1934 shelf_disabling_extensions_.find(extension); |
1936 if (iter != shelf_disabling_extensions_.end()) | 1935 if (iter != shelf_disabling_extensions_.end()) |
1937 shelf_disabling_extensions_.erase(iter); | 1936 shelf_disabling_extensions_.erase(iter); |
1938 } | 1937 } |
1939 | 1938 |
1940 } // namespace extensions | 1939 } // namespace extensions |
OLD | NEW |