| 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> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 namespace cast_channel { | 28 namespace cast_channel { |
| 29 | 29 |
| 30 struct AuthResult; | 30 struct AuthResult; |
| 31 class CastSocket; | 31 class CastSocket; |
| 32 | 32 |
| 33 static const int kMaxSocketsToLog = 50; | 33 static const int kMaxSocketsToLog = 50; |
| 34 static const int kMaxEventsPerSocket = 2000; | 34 static const int kMaxEventsPerSocket = 2000; |
| 35 | 35 |
| 36 // Logs information of each channel and sockets and exports the log as | 36 // Logs information of each channel and sockets and exports the log as |
| 37 // a blob. Logger is done on the IO thread. | 37 // a blob. Logger is done on the IO thread. |
| 38 class Logger : public base::RefCounted<Logger> { | 38 class Logger : public base::RefCountedThreadSafe<Logger> { |
| 39 public: | 39 public: |
| 40 // |clock|: Clock used for generating timestamps for the events. Owned by | 40 // |clock|: Clock used for generating timestamps for the events. Owned by |
| 41 // this class. | 41 // this class. |
| 42 // |unix_epoch_time|: The Time that corresponds to the Unix epoch. | 42 // |unix_epoch_time|: The Time that corresponds to the Unix epoch. |
| 43 // Can be set to other values (e.g. zero) for testing purposes. | 43 // Can be set to other values (e.g. zero) for testing purposes. |
| 44 // | 44 // |
| 45 // See crbug.com/518951 for information on why base::Clock | 45 // See crbug.com/518951 for information on why base::Clock |
| 46 // is used instead of base::TickClock. | 46 // is used instead of base::TickClock. |
| 47 Logger(std::unique_ptr<base::Clock> clock, base::Time unix_epoch_time); | 47 Logger(std::unique_ptr<base::Clock> clock, base::Time unix_epoch_time); |
| 48 | 48 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 // Clears the internal map. | 85 // Clears the internal map. |
| 86 void Reset(); | 86 void Reset(); |
| 87 | 87 |
| 88 // Returns the last errors logged for |channel_id|. If the the logs for | 88 // Returns the last errors logged for |channel_id|. If the the logs for |
| 89 // |channel_id| are evicted before this is called, returns a LastErrors with | 89 // |channel_id| are evicted before this is called, returns a LastErrors with |
| 90 // no errors. This may happen if errors are logged and retrieved in different | 90 // no errors. This may happen if errors are logged and retrieved in different |
| 91 // tasks. | 91 // tasks. |
| 92 LastErrors GetLastErrors(int channel_id) const; | 92 LastErrors GetLastErrors(int channel_id) const; |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 friend class base::RefCounted<Logger>; | 95 friend class base::RefCountedThreadSafe<Logger>; |
| 96 ~Logger(); | 96 ~Logger(); |
| 97 | 97 |
| 98 struct AggregatedSocketEventLog { | 98 struct AggregatedSocketEventLog { |
| 99 public: | 99 public: |
| 100 AggregatedSocketEventLog(); | 100 AggregatedSocketEventLog(); |
| 101 ~AggregatedSocketEventLog(); | 101 ~AggregatedSocketEventLog(); |
| 102 | 102 |
| 103 // Partially constructed AggregatedSocketEvent proto populated by Logger. | 103 // Partially constructed AggregatedSocketEvent proto populated by Logger. |
| 104 // Contains top level info such as channel ID, IP end point and channel | 104 // Contains top level info such as channel ID, IP end point and channel |
| 105 // auth type. | 105 // auth type. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 base::ThreadChecker thread_checker_; | 138 base::ThreadChecker thread_checker_; |
| 139 | 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(Logger); | 140 DISALLOW_COPY_AND_ASSIGN(Logger); |
| 141 }; | 141 }; |
| 142 } // namespace cast_channel | 142 } // namespace cast_channel |
| 143 } // namespace api | 143 } // namespace api |
| 144 } // namespace extensions | 144 } // namespace extensions |
| 145 | 145 |
| 146 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ | 146 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ |
| OLD | NEW |