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 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ |
6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ | 6 #define EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/linked_ptr.h" | |
17 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
18 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
19 #include "extensions/browser/api/cast_channel/logger_util.h" | 18 #include "extensions/browser/api/cast_channel/logger_util.h" |
20 #include "extensions/common/api/cast_channel/logging.pb.h" | 19 #include "extensions/common/api/cast_channel/logging.pb.h" |
21 #include "net/base/ip_endpoint.h" | 20 #include "net/base/ip_endpoint.h" |
22 | 21 |
23 namespace base { | 22 namespace base { |
24 class Clock; | 23 class Clock; |
25 } | 24 } |
26 | 25 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 proto::AggregatedSocketEvent aggregated_socket_event; | 106 proto::AggregatedSocketEvent aggregated_socket_event; |
108 // Events to be assigned to the AggregatedSocketEvent proto. Contains the | 107 // Events to be assigned to the AggregatedSocketEvent proto. Contains the |
109 // most recent |kMaxEventsPerSocket| entries. The oldest events are | 108 // most recent |kMaxEventsPerSocket| entries. The oldest events are |
110 // evicted as new events are logged. | 109 // evicted as new events are logged. |
111 std::deque<proto::SocketEvent> socket_events; | 110 std::deque<proto::SocketEvent> socket_events; |
112 | 111 |
113 // The most recent errors logged for the socket. | 112 // The most recent errors logged for the socket. |
114 LastErrors last_errors; | 113 LastErrors last_errors; |
115 }; | 114 }; |
116 | 115 |
117 typedef std::map<int, linked_ptr<AggregatedSocketEventLog> > | 116 using AggregatedSocketEventLogMap = |
118 AggregatedSocketEventLogMap; | 117 std::map<int, std::unique_ptr<AggregatedSocketEventLog>>; |
119 | 118 |
120 // Returns a SocketEvent proto with common fields (EventType, timestamp) | 119 // Returns a SocketEvent proto with common fields (EventType, timestamp) |
121 // populated. | 120 // populated. |
122 proto::SocketEvent CreateEvent(proto::EventType event_type); | 121 proto::SocketEvent CreateEvent(proto::EventType event_type); |
123 | 122 |
124 // Records |event| associated with |channel_id|. | 123 // Records |event| associated with |channel_id|. |
125 // If the internal map is already logging maximum number of sockets and this | 124 // If the internal map is already logging maximum number of sockets and this |
126 // is a new socket, the socket with the smallest channel id will be discarded. | 125 // is a new socket, the socket with the smallest channel id will be discarded. |
127 // Returns a reference to the AggregatedSocketEvent proto created/modified. | 126 // Returns a reference to the AggregatedSocketEvent proto created/modified. |
128 proto::AggregatedSocketEvent& LogSocketEvent( | 127 proto::AggregatedSocketEvent& LogSocketEvent( |
129 int channel_id, | 128 int channel_id, |
130 const proto::SocketEvent& socket_event); | 129 const proto::SocketEvent& socket_event); |
131 | 130 |
132 std::unique_ptr<base::Clock> clock_; | 131 std::unique_ptr<base::Clock> clock_; |
133 AggregatedSocketEventLogMap aggregated_socket_events_; | 132 AggregatedSocketEventLogMap aggregated_socket_events_; |
134 base::Time unix_epoch_time_; | 133 base::Time unix_epoch_time_; |
135 | 134 |
136 // Log proto holding global statistics. | 135 // Log proto holding global statistics. |
137 proto::Log log_; | 136 proto::Log log_; |
138 | 137 |
139 base::ThreadChecker thread_checker_; | 138 base::ThreadChecker thread_checker_; |
140 | 139 |
141 DISALLOW_COPY_AND_ASSIGN(Logger); | 140 DISALLOW_COPY_AND_ASSIGN(Logger); |
142 }; | 141 }; |
143 } // namespace cast_channel | 142 } // namespace cast_channel |
144 } // namespace api | 143 } // namespace api |
145 } // namespace extensions | 144 } // namespace extensions |
146 | 145 |
147 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ | 146 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ |
OLD | NEW |