| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 thread_checker_.DetachFromThread(); |
| 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(thread_checker_.CalledOnValidThread()); |
| 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); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |