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

Side by Side Diff: chrome/browser/download/download_service.cc

Issue 8351052: Created a DownloadManager interface, for use in unit tests.. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved comment. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/download/download_service.h" 5 #include "chrome/browser/download/download_service.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/download/chrome_download_manager_delegate.h" 8 #include "chrome/browser/download/chrome_download_manager_delegate.h"
9 #include "chrome/browser/download/download_service_factory.h" 9 #include "chrome/browser/download/download_service_factory.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 17 matching lines...) Expand all
28 DownloadIdFactory* DownloadService::GetDownloadIdFactory() const { 28 DownloadIdFactory* DownloadService::GetDownloadIdFactory() const {
29 return id_factory_.get(); 29 return id_factory_.get();
30 } 30 }
31 31
32 DownloadManager* DownloadService::GetDownloadManager() { 32 DownloadManager* DownloadService::GetDownloadManager() {
33 if (!download_manager_created_) { 33 if (!download_manager_created_) {
34 // In case the delegate has already been set by 34 // In case the delegate has already been set by
35 // SetDownloadManagerDelegateForTesting. 35 // SetDownloadManagerDelegateForTesting.
36 if (!manager_delegate_.get()) 36 if (!manager_delegate_.get())
37 manager_delegate_ = new ChromeDownloadManagerDelegate(profile_); 37 manager_delegate_ = new ChromeDownloadManagerDelegate(profile_);
38 manager_ = new DownloadManager( 38 manager_ = new DownloadManagerImpl(
39 manager_delegate_.get(), 39 manager_delegate_.get(),
40 id_factory_.get(), 40 id_factory_.get(),
41 g_browser_process->download_status_updater()); 41 g_browser_process->download_status_updater());
42 manager_->Init(profile_); 42 manager_->Init(profile_);
43 manager_delegate_->SetDownloadManager(manager_); 43 manager_delegate_->SetDownloadManager(manager_);
44 download_manager_created_ = true; 44 download_manager_created_ = true;
45 } 45 }
46 return manager_.get(); 46 return manager_.get();
47 } 47 }
48 48
49 bool DownloadService::HasCreatedDownloadManager() { 49 bool DownloadService::HasCreatedDownloadManager() {
50 return download_manager_created_; 50 return download_manager_created_;
51 } 51 }
52 52
53 int DownloadService::DownloadCount() const { 53 int DownloadService::DownloadCount() const {
54 return download_manager_created_ ? manager_->in_progress_count() : 0; 54 return download_manager_created_ ? manager_->InProgressCount() : 0;
55 } 55 }
56 56
57 // static 57 // static
58 int DownloadService::DownloadCountAllProfiles() { 58 int DownloadService::DownloadCountAllProfiles() {
59 std::vector<Profile*> profiles( 59 std::vector<Profile*> profiles(
60 g_browser_process->profile_manager()->GetLoadedProfiles()); 60 g_browser_process->profile_manager()->GetLoadedProfiles());
61 61
62 int count = 0; 62 int count = 0;
63 for (std::vector<Profile*>::iterator it = profiles.begin(); 63 for (std::vector<Profile*>::iterator it = profiles.begin();
64 it < profiles.end(); ++it) { 64 it < profiles.end(); ++it) {
(...skipping 26 matching lines...) Expand all
91 // Resetting here will guarantee that any attempts to get the 91 // Resetting here will guarantee that any attempts to get the
92 // DownloadManager after shutdown will return null. 92 // DownloadManager after shutdown will return null.
93 // 93 //
94 // TODO(rdsmith): Figure out how to guarantee when the last reference 94 // TODO(rdsmith): Figure out how to guarantee when the last reference
95 // will be released and make DownloadManager not RefCountedThreadSafe<>. 95 // will be released and make DownloadManager not RefCountedThreadSafe<>.
96 manager_.release(); 96 manager_.release();
97 } 97 }
98 if (manager_delegate_.get()) 98 if (manager_delegate_.get())
99 manager_delegate_.release(); 99 manager_delegate_.release();
100 } 100 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698