| 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 <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace cast_channel { | 26 namespace cast_channel { |
| 27 | 27 |
| 28 struct AuthResult; | 28 struct AuthResult; |
| 29 class CastSocket; | 29 class CastSocket; |
| 30 | 30 |
| 31 static const int kMaxSocketsToLog = 50; | 31 static const int kMaxSocketsToLog = 50; |
| 32 static const int kMaxEventsPerSocket = 2000; | 32 static const int kMaxEventsPerSocket = 2000; |
| 33 | 33 |
| 34 // Logs information of each channel and sockets and exports the log as | 34 // Logs information of each channel and sockets and exports the log as |
| 35 // a blob. Logger is done on the IO thread. | 35 // a blob. Logger is done on the IO thread. |
| 36 class Logger : public base::RefCounted<Logger> { | 36 // TODO(mgiuca): Avoid using UnsafeRefCounted. http://crbug.com/469952. |
| 37 class Logger : public base::UnsafeRefCounted<Logger> { |
| 37 public: | 38 public: |
| 38 // |clock|: Clock used for generating timestamps for the events. Owned by | 39 // |clock|: Clock used for generating timestamps for the events. Owned by |
| 39 // this class. | 40 // this class. |
| 40 // |unix_epoch_time_ticks|: The TimeTicks that corresponds to Unix epoch. | 41 // |unix_epoch_time_ticks|: The TimeTicks that corresponds to Unix epoch. |
| 41 Logger(scoped_ptr<base::TickClock> clock, | 42 Logger(scoped_ptr<base::TickClock> clock, |
| 42 base::TimeTicks unix_epoch_time_ticks); | 43 base::TimeTicks unix_epoch_time_ticks); |
| 43 | 44 |
| 44 // For newly created sockets. Will create an event and log a | 45 // For newly created sockets. Will create an event and log a |
| 45 // CAST_SOCKET_CREATED event. | 46 // CAST_SOCKET_CREATED event. |
| 46 void LogNewSocketEvent(const CastSocket& cast_socket); | 47 void LogNewSocketEvent(const CastSocket& cast_socket); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Clears the internal map. | 81 // Clears the internal map. |
| 81 void Reset(); | 82 void Reset(); |
| 82 | 83 |
| 83 // Returns the last errors logged for |channel_id|. If the the logs for | 84 // Returns the last errors logged for |channel_id|. If the the logs for |
| 84 // |channel_id| are evicted before this is called, returns a LastErrors with | 85 // |channel_id| are evicted before this is called, returns a LastErrors with |
| 85 // no errors. This may happen if errors are logged and retrieved in different | 86 // no errors. This may happen if errors are logged and retrieved in different |
| 86 // tasks. | 87 // tasks. |
| 87 LastErrors GetLastErrors(int channel_id) const; | 88 LastErrors GetLastErrors(int channel_id) const; |
| 88 | 89 |
| 89 private: | 90 private: |
| 90 friend class base::RefCounted<Logger>; | 91 friend class base::UnsafeRefCounted<Logger>; |
| 91 ~Logger(); | 92 ~Logger(); |
| 92 | 93 |
| 93 struct AggregatedSocketEventLog { | 94 struct AggregatedSocketEventLog { |
| 94 public: | 95 public: |
| 95 AggregatedSocketEventLog(); | 96 AggregatedSocketEventLog(); |
| 96 ~AggregatedSocketEventLog(); | 97 ~AggregatedSocketEventLog(); |
| 97 | 98 |
| 98 // Partially constructed AggregatedSocketEvent proto populated by Logger. | 99 // Partially constructed AggregatedSocketEvent proto populated by Logger. |
| 99 // Contains top level info such as channel ID, IP end point and channel | 100 // Contains top level info such as channel ID, IP end point and channel |
| 100 // auth type. | 101 // auth type. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 133 |
| 133 base::ThreadChecker thread_checker_; | 134 base::ThreadChecker thread_checker_; |
| 134 | 135 |
| 135 DISALLOW_COPY_AND_ASSIGN(Logger); | 136 DISALLOW_COPY_AND_ASSIGN(Logger); |
| 136 }; | 137 }; |
| 137 } // namespace cast_channel | 138 } // namespace cast_channel |
| 138 } // namespace core_api | 139 } // namespace core_api |
| 139 } // namespace extensions | 140 } // namespace extensions |
| 140 | 141 |
| 141 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ | 142 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ |
| OLD | NEW |