Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: extensions/browser/api/cast_channel/logger.h

Issue 2689483003: Make cast_channel::Logger RefCountedThreadSafe (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698