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

Side by Side Diff: net/proxy/proxy_resolver_v8_tracing.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/log/net_log_util.cc ('k') | net/proxy/proxy_script_decider.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/proxy/proxy_resolver_v8_tracing.h" 5 #include "net/proxy/proxy_resolver_v8_tracing.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/synchronization/cancellation_flag.h" 10 #include "base/synchronization/cancellation_flag.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // under the tracing optimization. It is not expected to hit this normally. 47 // under the tracing optimization. It is not expected to hit this normally.
48 const size_t kMaxUniqueResolveDnsPerExec = 20; 48 const size_t kMaxUniqueResolveDnsPerExec = 20;
49 49
50 // Approximate number of bytes to use for buffering alerts() and errors. 50 // Approximate number of bytes to use for buffering alerts() and errors.
51 // This is a failsafe in case repeated executions of the script causes 51 // This is a failsafe in case repeated executions of the script causes
52 // too much memory bloat. It is not expected for well behaved scripts to 52 // too much memory bloat. It is not expected for well behaved scripts to
53 // hit this. (In fact normal scripts should not even have alerts() or errors). 53 // hit this. (In fact normal scripts should not even have alerts() or errors).
54 const size_t kMaxAlertsAndErrorsBytes = 2048; 54 const size_t kMaxAlertsAndErrorsBytes = 2048;
55 55
56 // Returns event parameters for a PAC error message (line number + message). 56 // Returns event parameters for a PAC error message (line number + message).
57 base::Value* NetLogErrorCallback(int line_number, 57 scoped_ptr<base::Value> NetLogErrorCallback(
58 const base::string16* message, 58 int line_number,
59 NetLogCaptureMode /* capture_mode */) { 59 const base::string16* message,
60 base::DictionaryValue* dict = new base::DictionaryValue(); 60 NetLogCaptureMode /* capture_mode */) {
61 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
61 dict->SetInteger("line_number", line_number); 62 dict->SetInteger("line_number", line_number);
62 dict->SetString("message", *message); 63 dict->SetString("message", *message);
63 return dict; 64 return dict.Pass();
64 } 65 }
65 66
66 } // namespace 67 } // namespace
67 68
68 // The Job class is responsible for executing GetProxyForURL() and 69 // The Job class is responsible for executing GetProxyForURL() and
69 // SetPacScript(), since both of these operations share similar code. 70 // SetPacScript(), since both of these operations share similar code.
70 // 71 //
71 // The DNS for these operations can operate in either blocking or 72 // The DNS for these operations can operate in either blocking or
72 // non-blocking mode. Blocking mode is used as a fallback when the PAC script 73 // non-blocking mode. Blocking mode is used as a fallback when the PAC script
73 // seems to be misbehaving under the tracing optimization. 74 // seems to be misbehaving under the tracing optimization.
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 // error 912 // error
912 // ------------------- 913 // -------------------
913 if (line_number == -1) 914 if (line_number == -1)
914 VLOG(1) << "PAC-error: " << message; 915 VLOG(1) << "PAC-error: " << message;
915 else 916 else
916 VLOG(1) << "PAC-error: " << "line: " << line_number << ": " << message; 917 VLOG(1) << "PAC-error: " << "line: " << line_number << ": " << message;
917 918
918 // Send the error to the NetLog. 919 // Send the error to the NetLog.
919 LogEventToCurrentRequestAndGlobally( 920 LogEventToCurrentRequestAndGlobally(
920 NetLog::TYPE_PAC_JAVASCRIPT_ERROR, 921 NetLog::TYPE_PAC_JAVASCRIPT_ERROR,
921 base::Bind(&NetLogErrorCallback, line_number, &message)); 922 base::Bind(NetLogErrorCallback, line_number, &message));
922 923
923 if (error_observer()) 924 if (error_observer())
924 error_observer()->OnPACScriptError(line_number, message); 925 error_observer()->OnPACScriptError(line_number, message);
925 } 926 }
926 } 927 }
927 928
928 void ProxyResolverV8Tracing::Job::LogEventToCurrentRequestAndGlobally( 929 void ProxyResolverV8Tracing::Job::LogEventToCurrentRequestAndGlobally(
929 NetLog::EventType type, 930 NetLog::EventType type,
930 const NetLog::ParametersCallback& parameters_callback) { 931 const NetLog::ParametersCallback& parameters_callback) {
931 CheckIsOnWorkerThread(); 932 CheckIsOnWorkerThread();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 DCHECK(!set_pac_script_job_.get()); 1026 DCHECK(!set_pac_script_job_.get());
1026 CHECK_EQ(0, num_outstanding_callbacks_); 1027 CHECK_EQ(0, num_outstanding_callbacks_);
1027 1028
1028 set_pac_script_job_ = new Job(this); 1029 set_pac_script_job_ = new Job(this);
1029 set_pac_script_job_->StartSetPacScript(script_data, callback); 1030 set_pac_script_job_->StartSetPacScript(script_data, callback);
1030 1031
1031 return ERR_IO_PENDING; 1032 return ERR_IO_PENDING;
1032 } 1033 }
1033 1034
1034 } // namespace net 1035 } // namespace net
OLDNEW
« no previous file with comments | « net/log/net_log_util.cc ('k') | net/proxy/proxy_script_decider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698