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

Side by Side Diff: content/browser/download/drag_download_file.cc

Issue 10535026: Move creation and ownership of DownloadManager from the embedder to content. This matches all the o… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros compile Created 8 years, 6 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 | Annotate | Revision Log
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 "content/browser/download/drag_download_file.h" 5 #include "content/browser/download/drag_download_file.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/browser/download/download_stats.h" 10 #include "content/browser/download/download_stats.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/public/browser/browser_context.h" 12 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/download_item.h" 14 #include "content/public/browser/download_item.h"
15 #include "content/public/browser/download_save_info.h" 15 #include "content/public/browser/download_save_info.h"
16 #include "content/public/browser/download_url_parameters.h" 16 #include "content/public/browser/download_url_parameters.h"
17 #include "net/base/file_stream.h" 17 #include "net/base/file_stream.h"
18 18
19 using content::BrowserContext;
19 using content::BrowserThread; 20 using content::BrowserThread;
20 using content::DownloadItem; 21 using content::DownloadItem;
21 using content::DownloadManager; 22 using content::DownloadManager;
22 using content::DownloadUrlParameters; 23 using content::DownloadUrlParameters;
23 using content::WebContents; 24 using content::WebContents;
24 25
25 DragDownloadFile::DragDownloadFile( 26 DragDownloadFile::DragDownloadFile(
26 const FilePath& file_name_or_path, 27 const FilePath& file_name_or_path,
27 linked_ptr<net::FileStream> file_stream, 28 linked_ptr<net::FileStream> file_stream,
28 const GURL& url, 29 const GURL& url,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 #if defined(OS_WIN) 121 #if defined(OS_WIN)
121 // DownloadManager could only be invoked from the UI thread. 122 // DownloadManager could only be invoked from the UI thread.
122 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 123 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
123 BrowserThread::PostTask( 124 BrowserThread::PostTask(
124 BrowserThread::UI, FROM_HERE, 125 BrowserThread::UI, FROM_HERE,
125 base::Bind(&DragDownloadFile::InitiateDownload, this)); 126 base::Bind(&DragDownloadFile::InitiateDownload, this));
126 return; 127 return;
127 } 128 }
128 #endif 129 #endif
129 130
130 download_manager_ = web_contents_->GetBrowserContext()->GetDownloadManager(); 131 download_manager_ = BrowserContext::GetDownloadManager(
132 web_contents_->GetBrowserContext());
131 download_manager_observer_added_ = true; 133 download_manager_observer_added_ = true;
132 download_manager_->AddObserver(this); 134 download_manager_->AddObserver(this);
133 135
134 content::DownloadSaveInfo save_info; 136 content::DownloadSaveInfo save_info;
135 save_info.file_path = file_path_; 137 save_info.file_path = file_path_;
136 save_info.file_stream = file_stream_; 138 save_info.file_stream = file_stream_;
137 139
138 download_stats::RecordDownloadSource( 140 download_stats::RecordDownloadSource(
139 download_stats::INITIATED_BY_DRAG_N_DROP); 141 download_stats::INITIATED_BY_DRAG_N_DROP);
140 scoped_ptr<DownloadUrlParameters> params( 142 scoped_ptr<DownloadUrlParameters> params(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 233
232 void DragDownloadFile::QuitNestedMessageLoop() { 234 void DragDownloadFile::QuitNestedMessageLoop() {
233 AssertCurrentlyOnDragThread(); 235 AssertCurrentlyOnDragThread();
234 236
235 if (is_running_nested_message_loop_) { 237 if (is_running_nested_message_loop_) {
236 is_running_nested_message_loop_ = false; 238 is_running_nested_message_loop_ = false;
237 MessageLoop::current()->Quit(); 239 MessageLoop::current()->Quit();
238 } 240 }
239 } 241 }
240 #endif 242 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698