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

Side by Side Diff: net/socket/nss_ssl_util.cc

Issue 10546162: NetLogEventParameter to Callback refactoring 9. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove comment 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
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/socket_error_params.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "net/socket/nss_ssl_util.h" 5 #include "net/socket/nss_ssl_util.h"
6 6
7 #include <nss.h> 7 #include <nss.h>
8 #include <secerr.h> 8 #include <secerr.h>
9 #include <ssl.h> 9 #include <ssl.h>
10 #include <sslerr.h> 10 #include <sslerr.h>
11 11
12 #include <string> 12 #include <string>
13 13
14 #include "base/bind.h"
14 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
17 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "crypto/nss_util.h" 20 #include "crypto/nss_util.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "net/base/net_log.h" 22 #include "net/base/net_log.h"
22 23
23 namespace net { 24 namespace net {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 LOG(WARNING) << "Unknown SSL error " << err 214 LOG(WARNING) << "Unknown SSL error " << err
214 << " mapped to net::ERR_SSL_PROTOCOL_ERROR"; 215 << " mapped to net::ERR_SSL_PROTOCOL_ERROR";
215 return ERR_SSL_PROTOCOL_ERROR; 216 return ERR_SSL_PROTOCOL_ERROR;
216 } 217 }
217 LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED"; 218 LOG(WARNING) << "Unknown error " << err << " mapped to net::ERR_FAILED";
218 return ERR_FAILED; 219 return ERR_FAILED;
219 } 220 }
220 } 221 }
221 } 222 }
222 223
223 // Extra parameters to attach to the NetLog when we receive an error in response 224 // Returns parameters to attach to the NetLog when we receive an error in
224 // to a call to an NSS function. Used instead of SSLErrorParams with 225 // response to a call to an NSS function. Used instead of
225 // events of type TYPE_SSL_NSS_ERROR. Automatically looks up last PR error. 226 // NetLogSSLErrorCallback with events of type TYPE_SSL_NSS_ERROR.
226 class SSLFailedNSSFunctionParams : public NetLog::EventParameters { 227 Value* NetLogSSLFailedNSSFunctionCallback(
227 public: 228 const char* function,
228 // |param| is ignored if it has a length of 0. 229 const char* param,
229 SSLFailedNSSFunctionParams(const std::string& function, 230 int ssl_lib_error,
230 const std::string& param) 231 NetLog::LogLevel /* log_level */) {
231 : function_(function), param_(param), ssl_lib_error_(PR_GetError()) { 232 DictionaryValue* dict = new DictionaryValue();
232 } 233 dict->SetString("function", function);
233 234 if (param[0] != '\0')
234 virtual Value* ToValue() const { 235 dict->SetString("param", param);
235 DictionaryValue* dict = new DictionaryValue(); 236 dict->SetInteger("ssl_lib_error", ssl_lib_error);
236 dict->SetString("function", function_); 237 return dict;
237 if (!param_.empty()) 238 }
238 dict->SetString("param", param_);
239 dict->SetInteger("ssl_lib_error", ssl_lib_error_);
240 return dict;
241 }
242
243 protected:
244 virtual ~SSLFailedNSSFunctionParams() {}
245
246 private:
247 const std::string function_;
248 const std::string param_;
249 const PRErrorCode ssl_lib_error_;
250 };
251 239
252 void LogFailedNSSFunction(const BoundNetLog& net_log, 240 void LogFailedNSSFunction(const BoundNetLog& net_log,
253 const char* function, 241 const char* function,
254 const char* param) { 242 const char* param) {
243 DCHECK(function);
244 DCHECK(param);
255 net_log.AddEvent( 245 net_log.AddEvent(
256 NetLog::TYPE_SSL_NSS_ERROR, 246 NetLog::TYPE_SSL_NSS_ERROR,
257 make_scoped_refptr(new SSLFailedNSSFunctionParams(function, param))); 247 base::Bind(&NetLogSSLFailedNSSFunctionCallback,
248 function, param, PR_GetError()));
258 } 249 }
259 250
260 } // namespace net 251 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.cc ('k') | net/socket/socket_error_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698