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

Side by Side Diff: content/browser/android/download_controller_android_impl.cc

Issue 16994004: Remove DownloadItem::Is*() in favor of DI::GetState() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@di-getstate-2
Patch Set: Rebased to fix new test, applied suggestions from bauerb and benjhayden Created 7 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
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/android/download_controller_android_impl.h" 5 #include "content/browser/android/download_controller_android_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ConvertUTF8ToJavaString(env, download_item->GetMimeType()); 247 ConvertUTF8ToJavaString(env, download_item->GetMimeType());
248 ScopedJavaLocalRef<jstring> jfilename = ConvertUTF8ToJavaString( 248 ScopedJavaLocalRef<jstring> jfilename = ConvertUTF8ToJavaString(
249 env, download_item->GetTargetFilePath().BaseName().value()); 249 env, download_item->GetTargetFilePath().BaseName().value());
250 Java_DownloadController_onDownloadStarted( 250 Java_DownloadController_onDownloadStarted(
251 env, GetJavaObject()->Controller(env).obj(), view.obj(), jfilename.obj(), 251 env, GetJavaObject()->Controller(env).obj(), view.obj(), jfilename.obj(),
252 jmime_type.obj()); 252 jmime_type.obj());
253 } 253 }
254 254
255 void DownloadControllerAndroidImpl::OnDownloadUpdated(DownloadItem* item) { 255 void DownloadControllerAndroidImpl::OnDownloadUpdated(DownloadItem* item) {
256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
257 if (item->IsDangerous() && !item->IsCancelled()) 257 if (item->IsDangerous() &&
258 (item->GetState() != DownloadItem::CANCELLED))
258 OnDangerousDownload(item); 259 OnDangerousDownload(item);
259 260
260 if (!item->IsComplete()) 261 if (item->GetState() != DownloadItem::COMPLETE)
261 return; 262 return;
262 263
263 // Multiple OnDownloadUpdated() notifications may be issued while the download 264 // Multiple OnDownloadUpdated() notifications may be issued while the download
264 // is in the COMPLETE state. Only handle one. 265 // is in the COMPLETE state. Only handle one.
265 item->RemoveObserver(this); 266 item->RemoveObserver(this);
266 267
267 // Call onDownloadCompleted 268 // Call onDownloadCompleted
268 JNIEnv* env = base::android::AttachCurrentThread(); 269 JNIEnv* env = base::android::AttachCurrentThread();
269 ScopedJavaLocalRef<jstring> jurl = 270 ScopedJavaLocalRef<jstring> jurl =
270 ConvertUTF8ToJavaString(env, item->GetURL().spec()); 271 ConvertUTF8ToJavaString(env, item->GetURL().spec());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 referer = referer_url.spec(); 382 referer = referer_url.spec();
382 if (!request->url_chain().empty()) { 383 if (!request->url_chain().empty()) {
383 original_url = request->url_chain().front(); 384 original_url = request->url_chain().front();
384 url = request->url_chain().back(); 385 url = request->url_chain().back();
385 } 386 }
386 } 387 }
387 388
388 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {} 389 DownloadControllerAndroidImpl::DownloadInfoAndroid::~DownloadInfoAndroid() {}
389 390
390 } // namespace content 391 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/downloads_dom_handler.cc ('k') | content/browser/download/download_item_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698