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

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

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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>
11 #include <map> 11 #include <map>
12 #include <memory>
12 #include <string> 13 #include <string>
13 14
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
19 #include "extensions/browser/api/cast_channel/logger_util.h" 19 #include "extensions/browser/api/cast_channel/logger_util.h"
20 #include "extensions/common/api/cast_channel/logging.pb.h" 20 #include "extensions/common/api/cast_channel/logging.pb.h"
21 #include "net/base/ip_endpoint.h" 21 #include "net/base/ip_endpoint.h"
22 22
23 namespace base { 23 namespace base {
24 class Clock; 24 class Clock;
25 } 25 }
26 26
27 namespace extensions { 27 namespace extensions {
(...skipping 10 matching lines...) Expand all
38 // a blob. Logger is done on the IO thread. 38 // a blob. Logger is done on the IO thread.
39 class Logger : public base::RefCounted<Logger> { 39 class Logger : public base::RefCounted<Logger> {
40 public: 40 public:
41 // |clock|: Clock used for generating timestamps for the events. Owned by 41 // |clock|: Clock used for generating timestamps for the events. Owned by
42 // this class. 42 // this class.
43 // |unix_epoch_time|: The Time that corresponds to the Unix epoch. 43 // |unix_epoch_time|: The Time that corresponds to the Unix epoch.
44 // Can be set to other values (e.g. zero) for testing purposes. 44 // Can be set to other values (e.g. zero) for testing purposes.
45 // 45 //
46 // See crbug.com/518951 for information on why base::Clock 46 // See crbug.com/518951 for information on why base::Clock
47 // is used instead of base::TickClock. 47 // is used instead of base::TickClock.
48 Logger(scoped_ptr<base::Clock> clock, base::Time unix_epoch_time); 48 Logger(std::unique_ptr<base::Clock> clock, base::Time unix_epoch_time);
49 49
50 // For newly created sockets. Will create an event and log a 50 // For newly created sockets. Will create an event and log a
51 // CAST_SOCKET_CREATED event. 51 // CAST_SOCKET_CREATED event.
52 void LogNewSocketEvent(const CastSocket& cast_socket); 52 void LogNewSocketEvent(const CastSocket& cast_socket);
53 53
54 void LogSocketEvent(int channel_id, proto::EventType event_type); 54 void LogSocketEvent(int channel_id, proto::EventType event_type);
55 void LogSocketEventWithDetails(int channel_id, 55 void LogSocketEventWithDetails(int channel_id,
56 proto::EventType event_type, 56 proto::EventType event_type,
57 const std::string& details); 57 const std::string& details);
58 58
(...skipping 15 matching lines...) Expand all
74 74
75 void LogSocketEventForMessage(int channel_id, 75 void LogSocketEventForMessage(int channel_id,
76 proto::EventType event_type, 76 proto::EventType event_type,
77 const std::string& message_namespace, 77 const std::string& message_namespace,
78 const std::string& details); 78 const std::string& details);
79 79
80 // Assembles logs collected so far and return it as a serialized Log proto, 80 // Assembles logs collected so far and return it as a serialized Log proto,
81 // compressed in gzip format. 81 // compressed in gzip format.
82 // If serialization or compression failed, returns nullptr. 82 // If serialization or compression failed, returns nullptr.
83 // |length|: If successful, assigned with size of compressed content. 83 // |length|: If successful, assigned with size of compressed content.
84 scoped_ptr<char[]> GetLogs(size_t* length) const; 84 std::unique_ptr<char[]> GetLogs(size_t* length) const;
85 85
86 // Clears the internal map. 86 // Clears the internal map.
87 void Reset(); 87 void Reset();
88 88
89 // Returns the last errors logged for |channel_id|. If the the logs for 89 // Returns the last errors logged for |channel_id|. If the the logs for
90 // |channel_id| are evicted before this is called, returns a LastErrors with 90 // |channel_id| are evicted before this is called, returns a LastErrors with
91 // no errors. This may happen if errors are logged and retrieved in different 91 // no errors. This may happen if errors are logged and retrieved in different
92 // tasks. 92 // tasks.
93 LastErrors GetLastErrors(int channel_id) const; 93 LastErrors GetLastErrors(int channel_id) const;
94 94
(...skipping 27 matching lines...) Expand all
122 proto::SocketEvent CreateEvent(proto::EventType event_type); 122 proto::SocketEvent CreateEvent(proto::EventType event_type);
123 123
124 // Records |event| associated with |channel_id|. 124 // Records |event| associated with |channel_id|.
125 // If the internal map is already logging maximum number of sockets and this 125 // 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. 126 // is a new socket, the socket with the smallest channel id will be discarded.
127 // Returns a reference to the AggregatedSocketEvent proto created/modified. 127 // Returns a reference to the AggregatedSocketEvent proto created/modified.
128 proto::AggregatedSocketEvent& LogSocketEvent( 128 proto::AggregatedSocketEvent& LogSocketEvent(
129 int channel_id, 129 int channel_id,
130 const proto::SocketEvent& socket_event); 130 const proto::SocketEvent& socket_event);
131 131
132 scoped_ptr<base::Clock> clock_; 132 std::unique_ptr<base::Clock> clock_;
133 AggregatedSocketEventLogMap aggregated_socket_events_; 133 AggregatedSocketEventLogMap aggregated_socket_events_;
134 base::Time unix_epoch_time_; 134 base::Time unix_epoch_time_;
135 135
136 // Log proto holding global statistics. 136 // Log proto holding global statistics.
137 proto::Log log_; 137 proto::Log log_;
138 138
139 base::ThreadChecker thread_checker_; 139 base::ThreadChecker thread_checker_;
140 140
141 DISALLOW_COPY_AND_ASSIGN(Logger); 141 DISALLOW_COPY_AND_ASSIGN(Logger);
142 }; 142 };
143 } // namespace cast_channel 143 } // namespace cast_channel
144 } // namespace api 144 } // namespace api
145 } // namespace extensions 145 } // namespace extensions
146 146
147 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_ 147 #endif // EXTENSIONS_BROWSER_API_CAST_CHANNEL_LOGGER_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/keep_alive_delegate_unittest.cc ('k') | extensions/browser/api/cast_channel/logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698