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

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

Issue 1135373002: Updated NetLog::ParametersCallback & all related calbacks returning value as scoped_ptr<base::Value… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « net/sdch/sdch_owner.cc ('k') | net/socket/socket_net_log_params.cc » ('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>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // CiphersCopy copies the zero-terminated array |in| to |out|. It returns the 72 // CiphersCopy copies the zero-terminated array |in| to |out|. It returns the
73 // number of cipher suite ids copied. 73 // number of cipher suite ids copied.
74 size_t CiphersCopy(const uint16* in, uint16* out) { 74 size_t CiphersCopy(const uint16* in, uint16* out) {
75 for (size_t i = 0; ; i++) { 75 for (size_t i = 0; ; i++) {
76 if (in[i] == 0) 76 if (in[i] == 0)
77 return i; 77 return i;
78 out[i] = in[i]; 78 out[i] = in[i];
79 } 79 }
80 } 80 }
81 81
82 base::Value* NetLogSSLErrorCallback(int net_error, 82 scoped_ptr<base::Value> NetLogSSLErrorCallback(
83 int ssl_lib_error, 83 int net_error,
84 NetLogCaptureMode /* capture_mode */) { 84 int ssl_lib_error,
85 base::DictionaryValue* dict = new base::DictionaryValue(); 85 NetLogCaptureMode /* capture_mode */) {
86 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
86 dict->SetInteger("net_error", net_error); 87 dict->SetInteger("net_error", net_error);
87 if (ssl_lib_error) 88 if (ssl_lib_error)
88 dict->SetInteger("ssl_lib_error", ssl_lib_error); 89 dict->SetInteger("ssl_lib_error", ssl_lib_error);
89 return dict; 90 return dict.Pass();
90 } 91 }
91 92
92 class NSSSSLInitSingleton { 93 class NSSSSLInitSingleton {
93 public: 94 public:
94 NSSSSLInitSingleton() : model_fd_(NULL) { 95 NSSSSLInitSingleton() : model_fd_(NULL) {
95 crypto::EnsureNSSInit(); 96 crypto::EnsureNSSInit();
96 97
97 NSS_SetDomesticPolicy(); 98 NSS_SetDomesticPolicy();
98 99
99 const PRUint16* const ssl_ciphers = SSL_GetImplementedCiphers(); 100 const PRUint16* const ssl_ciphers = SSL_GetImplementedCiphers();
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 LOG(WARNING) << "Unknown error " << err << " (" << err_name << ")" 375 LOG(WARNING) << "Unknown error " << err << " (" << err_name << ")"
375 << " mapped to net::ERR_FAILED"; 376 << " mapped to net::ERR_FAILED";
376 return ERR_FAILED; 377 return ERR_FAILED;
377 } 378 }
378 } 379 }
379 } 380 }
380 381
381 // Returns parameters to attach to the NetLog when we receive an error in 382 // Returns parameters to attach to the NetLog when we receive an error in
382 // response to a call to an NSS function. Used instead of 383 // response to a call to an NSS function. Used instead of
383 // NetLogSSLErrorCallback with events of type TYPE_SSL_NSS_ERROR. 384 // NetLogSSLErrorCallback with events of type TYPE_SSL_NSS_ERROR.
384 base::Value* NetLogSSLFailedNSSFunctionCallback( 385 scoped_ptr<base::Value> NetLogSSLFailedNSSFunctionCallback(
385 const char* function, 386 const char* function,
386 const char* param, 387 const char* param,
387 int ssl_lib_error, 388 int ssl_lib_error,
388 NetLogCaptureMode /* capture_mode */) { 389 NetLogCaptureMode /* capture_mode */) {
389 base::DictionaryValue* dict = new base::DictionaryValue(); 390 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
390 dict->SetString("function", function); 391 dict->SetString("function", function);
391 if (param[0] != '\0') 392 if (param[0] != '\0')
392 dict->SetString("param", param); 393 dict->SetString("param", param);
393 dict->SetInteger("ssl_lib_error", ssl_lib_error); 394 dict->SetInteger("ssl_lib_error", ssl_lib_error);
394 return dict; 395 return dict.Pass();
395 } 396 }
396 397
397 void LogFailedNSSFunction(const BoundNetLog& net_log, 398 void LogFailedNSSFunction(const BoundNetLog& net_log,
398 const char* function, 399 const char* function,
399 const char* param) { 400 const char* param) {
400 DCHECK(function); 401 DCHECK(function);
401 DCHECK(param); 402 DCHECK(param);
402 net_log.AddEvent( 403 net_log.AddEvent(NetLog::TYPE_SSL_NSS_ERROR,
403 NetLog::TYPE_SSL_NSS_ERROR, 404 base::Bind(NetLogSSLFailedNSSFunctionCallback, function,
404 base::Bind(&NetLogSSLFailedNSSFunctionCallback, 405 param, PR_GetError()));
405 function, param, PR_GetError()));
406 } 406 }
407 407
408 NetLog::ParametersCallback CreateNetLogSSLErrorCallback(int net_error, 408 NetLog::ParametersCallback CreateNetLogSSLErrorCallback(int net_error,
409 int ssl_lib_error) { 409 int ssl_lib_error) {
410 return base::Bind(&NetLogSSLErrorCallback, net_error, ssl_lib_error); 410 return base::Bind(NetLogSSLErrorCallback, net_error, ssl_lib_error);
411 } 411 }
412 412
413 } // namespace net 413 } // namespace net
OLDNEW
« no previous file with comments | « net/sdch/sdch_owner.cc ('k') | net/socket/socket_net_log_params.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698