| OLD | NEW |
| 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/extensions/extension_downloads_api.h" | 5 #include "chrome/browser/extensions/extension_downloads_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cctype> | 8 #include <cctype> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 request, | 194 request, |
| 195 save_info, | 195 save_info, |
| 196 iodata_->save_as, | 196 iodata_->save_as, |
| 197 base::Bind(&DownloadsDownloadFunction::OnStarted, this), | 197 base::Bind(&DownloadsDownloadFunction::OnStarted, this), |
| 198 iodata_->render_process_host_id, | 198 iodata_->render_process_host_id, |
| 199 iodata_->render_view_host_routing_id, | 199 iodata_->render_view_host_routing_id, |
| 200 *(iodata_->resource_context)); | 200 *(iodata_->resource_context)); |
| 201 iodata_.reset(); | 201 iodata_.reset(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 void DownloadsDownloadFunction::OnStarted(int dl_id, net::Error error) { | 204 void DownloadsDownloadFunction::OnStarted(DownloadId dl_id, net::Error error) { |
| 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 206 VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error; | 206 VLOG(1) << __FUNCTION__ << " " << dl_id << " " << error; |
| 207 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( | 207 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( |
| 208 this, &DownloadsDownloadFunction::RespondOnUIThread, dl_id, error)); | 208 this, &DownloadsDownloadFunction::RespondOnUIThread, |
| 209 dl_id.local(), error)); |
| 209 } | 210 } |
| 210 | 211 |
| 211 void DownloadsDownloadFunction::RespondOnUIThread(int dl_id, net::Error error) { | 212 void DownloadsDownloadFunction::RespondOnUIThread(int dl_id, net::Error error) { |
| 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 213 VLOG(1) << __FUNCTION__; | 214 VLOG(1) << __FUNCTION__; |
| 214 if (dl_id >= 0) { | 215 if (dl_id >= 0) { |
| 215 result_.reset(base::Value::CreateIntegerValue(dl_id)); | 216 result_.reset(base::Value::CreateIntegerValue(dl_id)); |
| 216 } else { | 217 } else { |
| 217 error_ = net::ErrorToString(error); | 218 error_ = net::ErrorToString(error); |
| 218 } | 219 } |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 ListValue args; | 480 ListValue args; |
| 480 args.Append(arg); | 481 args.Append(arg); |
| 481 std::string json_args; | 482 std::string json_args; |
| 482 base::JSONWriter::Write(&args, false, &json_args); | 483 base::JSONWriter::Write(&args, false, &json_args); |
| 483 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 484 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
| 484 event_name, | 485 event_name, |
| 485 json_args, | 486 json_args, |
| 486 profile_, | 487 profile_, |
| 487 GURL()); | 488 GURL()); |
| 488 } | 489 } |
| OLD | NEW |