OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_wrapper.h" | 5 #include "net/proxy/proxy_resolver_v8_tracing_wrapper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/log/net_log.h" | 15 #include "net/log/net_log.h" |
| 16 #include "net/log/net_log_event_type.h" |
16 #include "net/proxy/proxy_resolver_error_observer.h" | 17 #include "net/proxy/proxy_resolver_error_observer.h" |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Returns event parameters for a PAC error message (line number + message). | 22 // Returns event parameters for a PAC error message (line number + message). |
22 std::unique_ptr<base::Value> NetLogErrorCallback( | 23 std::unique_ptr<base::Value> NetLogErrorCallback( |
23 int line_number, | 24 int line_number, |
24 const base::string16* message, | 25 const base::string16* message, |
25 NetLogCaptureMode /* capture_mode */) { | 26 NetLogCaptureMode /* capture_mode */) { |
(...skipping 11 matching lines...) Expand all Loading... |
37 const BoundNetLog& bound_net_log) | 38 const BoundNetLog& bound_net_log) |
38 : error_observer_(error_observer), | 39 : error_observer_(error_observer), |
39 host_resolver_(host_resolver), | 40 host_resolver_(host_resolver), |
40 net_log_(net_log), | 41 net_log_(net_log), |
41 bound_net_log_(bound_net_log) {} | 42 bound_net_log_(bound_net_log) {} |
42 | 43 |
43 // ProxyResolverV8Tracing::Bindings overrides. | 44 // ProxyResolverV8Tracing::Bindings overrides. |
44 void Alert(const base::string16& message) override { | 45 void Alert(const base::string16& message) override { |
45 // Send to the NetLog. | 46 // Send to the NetLog. |
46 LogEventToCurrentRequestAndGlobally( | 47 LogEventToCurrentRequestAndGlobally( |
47 NetLog::TYPE_PAC_JAVASCRIPT_ALERT, | 48 NetLogEventType::PAC_JAVASCRIPT_ALERT, |
48 NetLog::StringCallback("message", &message)); | 49 NetLog::StringCallback("message", &message)); |
49 } | 50 } |
50 | 51 |
51 void OnError(int line_number, const base::string16& message) override { | 52 void OnError(int line_number, const base::string16& message) override { |
52 // Send the error to the NetLog. | 53 // Send the error to the NetLog. |
53 LogEventToCurrentRequestAndGlobally( | 54 LogEventToCurrentRequestAndGlobally( |
54 NetLog::TYPE_PAC_JAVASCRIPT_ERROR, | 55 NetLogEventType::PAC_JAVASCRIPT_ERROR, |
55 base::Bind(&NetLogErrorCallback, line_number, &message)); | 56 base::Bind(&NetLogErrorCallback, line_number, &message)); |
56 if (error_observer_) | 57 if (error_observer_) |
57 error_observer_->OnPACScriptError(line_number, message); | 58 error_observer_->OnPACScriptError(line_number, message); |
58 } | 59 } |
59 | 60 |
60 HostResolver* GetHostResolver() override { return host_resolver_; } | 61 HostResolver* GetHostResolver() override { return host_resolver_; } |
61 | 62 |
62 BoundNetLog GetBoundNetLog() override { return bound_net_log_; } | 63 BoundNetLog GetBoundNetLog() override { return bound_net_log_; } |
63 | 64 |
64 private: | 65 private: |
65 void LogEventToCurrentRequestAndGlobally( | 66 void LogEventToCurrentRequestAndGlobally( |
66 NetLog::EventType type, | 67 NetLogEventType type, |
67 const NetLog::ParametersCallback& parameters_callback) { | 68 const NetLog::ParametersCallback& parameters_callback) { |
68 bound_net_log_.AddEvent(type, parameters_callback); | 69 bound_net_log_.AddEvent(type, parameters_callback); |
69 | 70 |
70 // Emit to the global NetLog event stream. | 71 // Emit to the global NetLog event stream. |
71 if (net_log_) | 72 if (net_log_) |
72 net_log_->AddGlobalEntry(type, parameters_callback); | 73 net_log_->AddGlobalEntry(type, parameters_callback); |
73 } | 74 } |
74 | 75 |
75 ProxyResolverErrorObserver* error_observer_; | 76 ProxyResolverErrorObserver* error_observer_; |
76 HostResolver* host_resolver_; | 77 HostResolver* host_resolver_; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 int error) { | 188 int error) { |
188 if (error == OK) { | 189 if (error == OK) { |
189 resolver->reset(new ProxyResolverV8TracingWrapper( | 190 resolver->reset(new ProxyResolverV8TracingWrapper( |
190 std::move(*v8_resolver), net_log_, host_resolver_, | 191 std::move(*v8_resolver), net_log_, host_resolver_, |
191 std::move(error_observer))); | 192 std::move(error_observer))); |
192 } | 193 } |
193 callback.Run(error); | 194 callback.Run(error); |
194 } | 195 } |
195 | 196 |
196 } // namespace net | 197 } // namespace net |
OLD | NEW |