OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/logger.h" | 5 #include "components/cast_channel/logger.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "extensions/browser/api/cast_channel/cast_auth_util.h" | 14 #include "components/cast_channel/cast_auth_util.h" |
15 #include "extensions/browser/api/cast_channel/cast_socket.h" | 15 #include "components/cast_channel/cast_socket.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 | 17 |
18 namespace extensions { | |
19 namespace api { | |
20 namespace cast_channel { | 18 namespace cast_channel { |
21 | 19 |
22 using net::IPEndPoint; | 20 using net::IPEndPoint; |
23 using proto::EventType; | 21 using proto::EventType; |
24 using proto::Log; | 22 using proto::Log; |
25 using proto::SocketEvent; | 23 using proto::SocketEvent; |
26 | 24 |
27 namespace { | 25 namespace { |
28 | 26 |
29 proto::ChallengeReplyErrorType ChallegeReplyErrorToProto( | 27 proto::ChallengeReplyErrorType ChallegeReplyErrorToProto( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 LastErrors::LastErrors() | 87 LastErrors::LastErrors() |
90 : event_type(proto::EVENT_TYPE_UNKNOWN), | 88 : event_type(proto::EVENT_TYPE_UNKNOWN), |
91 challenge_reply_error_type(proto::CHALLENGE_REPLY_ERROR_NONE), | 89 challenge_reply_error_type(proto::CHALLENGE_REPLY_ERROR_NONE), |
92 net_return_value(net::OK) {} | 90 net_return_value(net::OK) {} |
93 | 91 |
94 LastErrors::~LastErrors() {} | 92 LastErrors::~LastErrors() {} |
95 | 93 |
96 Logger::Logger() { | 94 Logger::Logger() { |
97 // Logger may not be necessarily be created on the IO thread, but logging | 95 // Logger may not be necessarily be created on the IO thread, but logging |
98 // happens exclusively there. | 96 // happens exclusively there. |
99 thread_checker_.DetachFromThread(); | 97 DETACH_FROM_THREAD(thread_checker_); |
100 } | 98 } |
101 | 99 |
102 Logger::~Logger() { | 100 Logger::~Logger() {} |
103 } | |
104 | 101 |
105 void Logger::LogSocketEventWithRv(int channel_id, | 102 void Logger::LogSocketEventWithRv(int channel_id, |
106 EventType event_type, | 103 EventType event_type, |
107 int rv) { | 104 int rv) { |
108 DCHECK(thread_checker_.CalledOnValidThread()); | 105 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
109 | 106 |
110 SocketEvent event = CreateEvent(event_type); | 107 SocketEvent event = CreateEvent(event_type); |
111 event.set_net_return_value(rv); | 108 event.set_net_return_value(rv); |
112 | 109 |
113 LogSocketEvent(channel_id, event); | 110 LogSocketEvent(channel_id, event); |
114 } | 111 } |
115 | 112 |
116 void Logger::LogSocketChallengeReplyEvent(int channel_id, | 113 void Logger::LogSocketChallengeReplyEvent(int channel_id, |
117 const AuthResult& auth_result) { | 114 const AuthResult& auth_result) { |
118 DCHECK(thread_checker_.CalledOnValidThread()); | 115 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); |
119 | 116 |
120 SocketEvent event = CreateEvent(proto::AUTH_CHALLENGE_REPLY); | 117 SocketEvent event = CreateEvent(proto::AUTH_CHALLENGE_REPLY); |
121 event.set_challenge_reply_error_type( | 118 event.set_challenge_reply_error_type( |
122 ChallegeReplyErrorToProto(auth_result.error_type)); | 119 ChallegeReplyErrorToProto(auth_result.error_type)); |
123 | 120 |
124 LogSocketEvent(channel_id, event); | 121 LogSocketEvent(channel_id, event); |
125 } | 122 } |
126 | 123 |
127 LastErrors Logger::GetLastErrors(int channel_id) const { | 124 LastErrors Logger::GetLastErrors(int channel_id) const { |
128 LastErrorsMap::const_iterator it = last_errors_.find(channel_id); | 125 LastErrorsMap::const_iterator it = last_errors_.find(channel_id); |
(...skipping 16 matching lines...) Expand all Loading... |
145 | 142 |
146 void Logger::LogSocketEvent(int channel_id, const SocketEvent& socket_event) { | 143 void Logger::LogSocketEvent(int channel_id, const SocketEvent& socket_event) { |
147 LastErrorsMap::iterator it = last_errors_.find(channel_id); | 144 LastErrorsMap::iterator it = last_errors_.find(channel_id); |
148 if (it == last_errors_.end()) | 145 if (it == last_errors_.end()) |
149 last_errors_[channel_id] = LastErrors(); | 146 last_errors_[channel_id] = LastErrors(); |
150 | 147 |
151 MaybeSetLastErrors(socket_event, &last_errors_[channel_id]); | 148 MaybeSetLastErrors(socket_event, &last_errors_[channel_id]); |
152 } | 149 } |
153 | 150 |
154 } // namespace cast_channel | 151 } // namespace cast_channel |
155 } // namespace api | |
156 } // namespace extensions | |
OLD | NEW |