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

Unified 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: Update 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 side-by-side diff with in-line comments
Download patch
Index: net/socket/nss_ssl_util.cc
===================================================================
--- net/socket/nss_ssl_util.cc (revision 142108)
+++ net/socket/nss_ssl_util.cc (working copy)
@@ -11,6 +11,7 @@
#include <string>
+#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
@@ -220,41 +221,30 @@
}
}
-// Extra parameters to attach to the NetLog when we receive an error in response
-// to a call to an NSS function. Used instead of SSLErrorParams with
-// events of type TYPE_SSL_NSS_ERROR. Automatically looks up last PR error.
-class SSLFailedNSSFunctionParams : public NetLog::EventParameters {
- public:
- // |param| is ignored if it has a length of 0.
- SSLFailedNSSFunctionParams(const std::string& function,
- const std::string& param)
- : function_(function), param_(param), ssl_lib_error_(PR_GetError()) {
- }
+// Returns parameters to attach to the NetLog when we receive an error in
+// response to a call to an NSS function. Used instead of
+// NetLogSSLErrorCallback with events of type TYPE_SSL_NSS_ERROR.
+// Automatically looks up last PR error.
+Value* NetLogSSLFailedNSSFunctionCallback(
+ const char* function,
+ const char* param,
+ NetLog::LogLevel /* log_level */) {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetString("function", function);
+ if (param[0] != '\0')
+ dict->SetString("param", param);
+ dict->SetInteger("ssl_lib_error", PR_GetError());
eroman 2012/06/14 17:45:50 Please take PR_GetError() as a parameter. My conc
mmenke 2012/06/14 18:03:45 Done. I did think about that. Then I thought tha
+ return dict;
+}
- virtual Value* ToValue() const {
- DictionaryValue* dict = new DictionaryValue();
- dict->SetString("function", function_);
- if (!param_.empty())
- dict->SetString("param", param_);
- dict->SetInteger("ssl_lib_error", ssl_lib_error_);
- return dict;
- }
-
- protected:
- virtual ~SSLFailedNSSFunctionParams() {}
-
- private:
- const std::string function_;
- const std::string param_;
- const PRErrorCode ssl_lib_error_;
-};
-
void LogFailedNSSFunction(const BoundNetLog& net_log,
const char* function,
const char* param) {
+ DCHECK(function);
+ DCHECK(param);
net_log.AddEvent(
NetLog::TYPE_SSL_NSS_ERROR,
- make_scoped_refptr(new SSLFailedNSSFunctionParams(function, param)));
+ base::Bind(&NetLogSSLFailedNSSFunctionCallback, function, param));
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698