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

Side by Side Diff: content/browser/ssl/ssl_error_handler.cc

Issue 1005683003: favor DCHECK_CURRENTLY_ON for better logs in content/browser/[q-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 "content/browser/ssl/ssl_error_handler.h" 5 #include "content/browser/ssl/ssl_error_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/frame_host/navigation_controller_impl.h" 8 #include "content/browser/frame_host/navigation_controller_impl.h"
9 #include "content/browser/frame_host/render_frame_host_impl.h" 9 #include "content/browser/frame_host/render_frame_host_impl.h"
10 #include "content/browser/ssl/ssl_cert_error_handler.h" 10 #include "content/browser/ssl/ssl_cert_error_handler.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 void SSLErrorHandler::OnDispatched() { 50 void SSLErrorHandler::OnDispatched() {
51 TakeNoAction(); 51 TakeNoAction();
52 } 52 }
53 53
54 SSLCertErrorHandler* SSLErrorHandler::AsSSLCertErrorHandler() { 54 SSLCertErrorHandler* SSLErrorHandler::AsSSLCertErrorHandler() {
55 return NULL; 55 return NULL;
56 } 56 }
57 57
58 void SSLErrorHandler::Dispatch() { 58 void SSLErrorHandler::Dispatch() {
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 59 DCHECK_CURRENTLY_ON(BrowserThread::UI);
60 60
61 WebContents* web_contents = NULL; 61 WebContents* web_contents = NULL;
62 RenderFrameHost* render_frame_host = 62 RenderFrameHost* render_frame_host =
63 RenderFrameHost::FromID(render_process_id_, render_frame_id_); 63 RenderFrameHost::FromID(render_process_id_, render_frame_id_);
64 web_contents = WebContents::FromRenderFrameHost(render_frame_host); 64 web_contents = WebContents::FromRenderFrameHost(render_frame_host);
65 65
66 if (!web_contents) { 66 if (!web_contents) {
67 // We arrived on the UI thread, but the tab we're looking for is no longer 67 // We arrived on the UI thread, but the tab we're looking for is no longer
68 // here. 68 // here.
69 OnDispatchFailed(); 69 OnDispatchFailed();
70 return; 70 return;
71 } 71 }
72 72
73 // Hand ourselves off to the SSLManager. 73 // Hand ourselves off to the SSLManager.
74 manager_ = 74 manager_ =
75 static_cast<NavigationControllerImpl*>(&web_contents->GetController())-> 75 static_cast<NavigationControllerImpl*>(&web_contents->GetController())->
76 ssl_manager(); 76 ssl_manager();
77 OnDispatched(); 77 OnDispatched();
78 } 78 }
79 79
80 void SSLErrorHandler::CancelRequest() { 80 void SSLErrorHandler::CancelRequest() {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 81 DCHECK_CURRENTLY_ON(BrowserThread::UI);
82 82
83 // We need to complete this task on the IO thread. 83 // We need to complete this task on the IO thread.
84 BrowserThread::PostTask( 84 BrowserThread::PostTask(
85 BrowserThread::IO, FROM_HERE, 85 BrowserThread::IO, FROM_HERE,
86 base::Bind( 86 base::Bind(
87 &SSLErrorHandler::CompleteCancelRequest, this, net::ERR_ABORTED)); 87 &SSLErrorHandler::CompleteCancelRequest, this, net::ERR_ABORTED));
88 } 88 }
89 89
90 void SSLErrorHandler::DenyRequest() { 90 void SSLErrorHandler::DenyRequest() {
91 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 91 DCHECK_CURRENTLY_ON(BrowserThread::UI);
92 92
93 // We need to complete this task on the IO thread. 93 // We need to complete this task on the IO thread.
94 BrowserThread::PostTask( 94 BrowserThread::PostTask(
95 BrowserThread::IO, FROM_HERE, 95 BrowserThread::IO, FROM_HERE,
96 base::Bind( 96 base::Bind(
97 &SSLErrorHandler::CompleteCancelRequest, this, 97 &SSLErrorHandler::CompleteCancelRequest, this,
98 net::ERR_INSECURE_RESPONSE)); 98 net::ERR_INSECURE_RESPONSE));
99 } 99 }
100 100
101 void SSLErrorHandler::ContinueRequest() { 101 void SSLErrorHandler::ContinueRequest() {
102 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 102 DCHECK_CURRENTLY_ON(BrowserThread::UI);
103 103
104 // We need to complete this task on the IO thread. 104 // We need to complete this task on the IO thread.
105 BrowserThread::PostTask( 105 BrowserThread::PostTask(
106 BrowserThread::IO, FROM_HERE, 106 BrowserThread::IO, FROM_HERE,
107 base::Bind(&SSLErrorHandler::CompleteContinueRequest, this)); 107 base::Bind(&SSLErrorHandler::CompleteContinueRequest, this));
108 } 108 }
109 109
110 void SSLErrorHandler::TakeNoAction() { 110 void SSLErrorHandler::TakeNoAction() {
111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 111 DCHECK_CURRENTLY_ON(BrowserThread::UI);
112 112
113 // We need to complete this task on the IO thread. 113 // We need to complete this task on the IO thread.
114 BrowserThread::PostTask( 114 BrowserThread::PostTask(
115 BrowserThread::IO, FROM_HERE, 115 BrowserThread::IO, FROM_HERE,
116 base::Bind(&SSLErrorHandler::CompleteTakeNoAction, this)); 116 base::Bind(&SSLErrorHandler::CompleteTakeNoAction, this));
117 } 117 }
118 118
119 void SSLErrorHandler::CompleteCancelRequest(int error) { 119 void SSLErrorHandler::CompleteCancelRequest(int error) {
120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 120 DCHECK_CURRENTLY_ON(BrowserThread::IO);
121 121
122 // It is important that we notify the net::URLRequest only once. If we try 122 // It is important that we notify the net::URLRequest only once. If we try
123 // to notify the request twice, it may no longer exist and |this| might have 123 // to notify the request twice, it may no longer exist and |this| might have
124 // already have been deleted. 124 // already have been deleted.
125 DCHECK(!request_has_been_notified_); 125 DCHECK(!request_has_been_notified_);
126 if (request_has_been_notified_) 126 if (request_has_been_notified_)
127 return; 127 return;
128 128
129 SSLCertErrorHandler* cert_error = AsSSLCertErrorHandler(); 129 SSLCertErrorHandler* cert_error = AsSSLCertErrorHandler();
130 const SSLInfo* ssl_info = NULL; 130 const SSLInfo* ssl_info = NULL;
131 if (cert_error) 131 if (cert_error)
132 ssl_info = &cert_error->ssl_info(); 132 ssl_info = &cert_error->ssl_info();
133 if (delegate_.get()) 133 if (delegate_.get())
134 delegate_->CancelSSLRequest(error, ssl_info); 134 delegate_->CancelSSLRequest(error, ssl_info);
135 request_has_been_notified_ = true; 135 request_has_been_notified_ = true;
136 136
137 // We're done with this object on the IO thread. 137 // We're done with this object on the IO thread.
138 Release(); 138 Release();
139 } 139 }
140 140
141 void SSLErrorHandler::CompleteContinueRequest() { 141 void SSLErrorHandler::CompleteContinueRequest() {
142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 142 DCHECK_CURRENTLY_ON(BrowserThread::IO);
143 143
144 // It is important that we notify the net::URLRequest only once. If we try to 144 // It is important that we notify the net::URLRequest only once. If we try to
145 // notify the request twice, it may no longer exist and |this| might have 145 // notify the request twice, it may no longer exist and |this| might have
146 // already have been deleted. 146 // already have been deleted.
147 DCHECK(!request_has_been_notified_); 147 DCHECK(!request_has_been_notified_);
148 if (request_has_been_notified_) 148 if (request_has_been_notified_)
149 return; 149 return;
150 150
151 if (delegate_.get()) 151 if (delegate_.get())
152 delegate_->ContinueSSLRequest(); 152 delegate_->ContinueSSLRequest();
153 request_has_been_notified_ = true; 153 request_has_been_notified_ = true;
154 154
155 // We're done with this object on the IO thread. 155 // We're done with this object on the IO thread.
156 Release(); 156 Release();
157 } 157 }
158 158
159 void SSLErrorHandler::CompleteTakeNoAction() { 159 void SSLErrorHandler::CompleteTakeNoAction() {
160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 160 DCHECK_CURRENTLY_ON(BrowserThread::IO);
161 161
162 // It is important that we notify the net::URLRequest only once. If we try to 162 // It is important that we notify the net::URLRequest only once. If we try to
163 // notify the request twice, it may no longer exist and |this| might have 163 // notify the request twice, it may no longer exist and |this| might have
164 // already have been deleted. 164 // already have been deleted.
165 DCHECK(!request_has_been_notified_); 165 DCHECK(!request_has_been_notified_);
166 if (request_has_been_notified_) 166 if (request_has_been_notified_)
167 return; 167 return;
168 168
169 request_has_been_notified_ = true; 169 request_has_been_notified_ = true;
170 170
171 // We're done with this object on the IO thread. 171 // We're done with this object on the IO thread.
172 Release(); 172 Release();
173 } 173 }
174 174
175 } // namespace content 175 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognizer_impl_android.cc ('k') | content/browser/storage_partition_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698