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

Side by Side Diff: android_webview/browser/aw_login_delegate.cc

Issue 1013843002: favor DCHECK_CURRENTLY_ON for better logs in android_webview/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change a few more Created 5 years, 9 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 "android_webview/browser/aw_login_delegate.h" 5 #include "android_webview/browser/aw_login_delegate.h"
6 6
7 #include "android_webview/browser/aw_browser_context.h" 7 #include "android_webview/browser/aw_browser_context.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/supports_user_data.h" 10 #include "base/supports_user_data.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 AwLoginDelegate::~AwLoginDelegate() { 64 AwLoginDelegate::~AwLoginDelegate() {
65 // The Auth handler holds a ref count back on |this| object, so it should be 65 // The Auth handler holds a ref count back on |this| object, so it should be
66 // impossible to reach here while this object still owns an auth handler. 66 // impossible to reach here while this object still owns an auth handler.
67 DCHECK(!aw_http_auth_handler_); 67 DCHECK(!aw_http_auth_handler_);
68 } 68 }
69 69
70 void AwLoginDelegate::Proceed(const base::string16& user, 70 void AwLoginDelegate::Proceed(const base::string16& user,
71 const base::string16& password) { 71 const base::string16& password) {
72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 72 DCHECK_CURRENTLY_ON(BrowserThread::UI);
73 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 73 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
74 base::Bind(&AwLoginDelegate::ProceedOnIOThread, 74 base::Bind(&AwLoginDelegate::ProceedOnIOThread,
75 this, user, password)); 75 this, user, password));
76 } 76 }
77 77
78 void AwLoginDelegate::Cancel() { 78 void AwLoginDelegate::Cancel() {
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 79 DCHECK_CURRENTLY_ON(BrowserThread::UI);
80 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 80 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
81 base::Bind(&AwLoginDelegate::CancelOnIOThread, this)); 81 base::Bind(&AwLoginDelegate::CancelOnIOThread, this));
82 } 82 }
83 83
84 void AwLoginDelegate::HandleHttpAuthRequestOnUIThread( 84 void AwLoginDelegate::HandleHttpAuthRequestOnUIThread(
85 bool first_auth_attempt) { 85 bool first_auth_attempt) {
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 86 DCHECK_CURRENTLY_ON(BrowserThread::UI);
87 87
88 aw_http_auth_handler_.reset(AwHttpAuthHandlerBase::Create( 88 aw_http_auth_handler_.reset(AwHttpAuthHandlerBase::Create(
89 this, auth_info_.get(), first_auth_attempt)); 89 this, auth_info_.get(), first_auth_attempt));
90 90
91 RenderFrameHost* render_frame_host = RenderFrameHost::FromID( 91 RenderFrameHost* render_frame_host = RenderFrameHost::FromID(
92 render_process_id_, render_frame_id_); 92 render_process_id_, render_frame_id_);
93 WebContents* web_contents = WebContents::FromRenderFrameHost( 93 WebContents* web_contents = WebContents::FromRenderFrameHost(
94 render_frame_host); 94 render_frame_host);
95 if (!aw_http_auth_handler_->HandleOnUIThread(web_contents)) { 95 if (!aw_http_auth_handler_->HandleOnUIThread(web_contents)) {
96 Cancel(); 96 Cancel();
97 return; 97 return;
98 } 98 }
99 } 99 }
100 100
101 void AwLoginDelegate::CancelOnIOThread() { 101 void AwLoginDelegate::CancelOnIOThread() {
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 102 DCHECK_CURRENTLY_ON(BrowserThread::IO);
103 if (request_) { 103 if (request_) {
104 request_->CancelAuth(); 104 request_->CancelAuth();
105 ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_); 105 ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_);
106 request_ = NULL; 106 request_ = NULL;
107 } 107 }
108 DeleteAuthHandlerSoon(); 108 DeleteAuthHandlerSoon();
109 } 109 }
110 110
111 void AwLoginDelegate::ProceedOnIOThread(const base::string16& user, 111 void AwLoginDelegate::ProceedOnIOThread(const base::string16& user,
112 const base::string16& password) { 112 const base::string16& password) {
113 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 113 DCHECK_CURRENTLY_ON(BrowserThread::IO);
114 if (request_) { 114 if (request_) {
115 request_->SetAuth(net::AuthCredentials(user, password)); 115 request_->SetAuth(net::AuthCredentials(user, password));
116 ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_); 116 ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(request_);
117 request_ = NULL; 117 request_ = NULL;
118 } 118 }
119 DeleteAuthHandlerSoon(); 119 DeleteAuthHandlerSoon();
120 } 120 }
121 121
122 void AwLoginDelegate::OnRequestCancelled() { 122 void AwLoginDelegate::OnRequestCancelled() {
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 123 DCHECK_CURRENTLY_ON(BrowserThread::IO);
124 request_ = NULL; 124 request_ = NULL;
125 DeleteAuthHandlerSoon(); 125 DeleteAuthHandlerSoon();
126 } 126 }
127 127
128 void AwLoginDelegate::DeleteAuthHandlerSoon() { 128 void AwLoginDelegate::DeleteAuthHandlerSoon() {
129 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 129 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
130 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 130 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
131 base::Bind(&AwLoginDelegate::DeleteAuthHandlerSoon, this)); 131 base::Bind(&AwLoginDelegate::DeleteAuthHandlerSoon, this));
132 return; 132 return;
133 } 133 }
134 aw_http_auth_handler_.reset(); 134 aw_http_auth_handler_.reset();
135 } 135 }
136 136
137 } // namespace android_webview 137 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/aw_form_database_service.cc ('k') | android_webview/browser/aw_request_interceptor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698