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

Side by Side Diff: net/log/net_log.h

Issue 1122483004: Remove NetLog::GetCaptureMode() and NetLogCaptureMode::None() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mmenke_refactor
Patch Set: second attempt at fixing int --> bool warning on windows Created 5 years, 7 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 | « net/http/http_network_transaction_unittest.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 NET_LOG_NET_LOG_H_ 5 #ifndef NET_LOG_NET_LOG_H_
6 #define NET_LOG_NET_LOG_H_ 6 #define NET_LOG_NET_LOG_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 200
201 // Emits a global event to the log stream, with its own unique source ID. 201 // Emits a global event to the log stream, with its own unique source ID.
202 void AddGlobalEntry(EventType type); 202 void AddGlobalEntry(EventType type);
203 void AddGlobalEntry(EventType type, 203 void AddGlobalEntry(EventType type,
204 const NetLog::ParametersCallback& parameters_callback); 204 const NetLog::ParametersCallback& parameters_callback);
205 205
206 // Returns a unique ID which can be used as a source ID. All returned IDs 206 // Returns a unique ID which can be used as a source ID. All returned IDs
207 // will be unique and greater than 0. 207 // will be unique and greater than 0.
208 uint32 NextID(); 208 uint32 NextID();
209 209
210 // Returns the capture mode for this NetLog. This is used to avoid computing 210 // Returns true if there are any observers attached to the NetLog. This can be
211 // and saving expensive log entries. 211 // used as an optimization to avoid emitting log entries when there is no
212 NetLogCaptureMode GetCaptureMode() const; 212 // chance that the data will be consumed.
213 bool IsCapturing() const;
213 214
214 // Adds an observer and sets its log capture mode. The observer must not be 215 // Adds an observer and sets its log capture mode. The observer must not be
215 // watching any NetLog, including this one, when this is called. 216 // watching any NetLog, including this one, when this is called.
216 // 217 //
217 // NetLog implementations must call NetLog::OnAddObserver to update the 218 // NetLog implementations must call NetLog::OnAddObserver to update the
218 // observer's internal state. 219 // observer's internal state.
219 // 220 //
220 // DEPRECATED: The ability to watch the netlog stream is being phased out 221 // DEPRECATED: The ability to watch the netlog stream is being phased out
221 // (crbug.com/472693) as it can be misused in production code. Please consult 222 // (crbug.com/472693) as it can be misused in production code. Please consult
222 // with a net/log OWNER before introducing a new dependency on this. 223 // with a net/log OWNER before introducing a new dependency on this.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 const base::string16* value); 288 const base::string16* value);
288 289
289 private: 290 private:
290 friend class BoundNetLog; 291 friend class BoundNetLog;
291 292
292 void AddEntry(EventType type, 293 void AddEntry(EventType type,
293 const Source& source, 294 const Source& source,
294 EventPhase phase, 295 EventPhase phase,
295 const NetLog::ParametersCallback* parameters_callback); 296 const NetLog::ParametersCallback* parameters_callback);
296 297
297 // Called whenever an observer is added or removed, or has its log 298 // Called whenever an observer is added or removed, to update
298 // capture mode changed. Must have acquired |lock_| prior to calling. 299 // |has_observers_|. Must have acquired |lock_| prior to calling.
299 void UpdateCaptureMode(); 300 void UpdateIsCapturing();
300 301
301 // |lock_| protects access to |observers_|. 302 // |lock_| protects access to |observers_|.
302 base::Lock lock_; 303 base::Lock lock_;
303 304
304 // Last assigned source ID. Incremented to get the next one. 305 // Last assigned source ID. Incremented to get the next one.
305 base::subtle::Atomic32 last_id_; 306 base::subtle::Atomic32 last_id_;
306 307
307 // The current capture mode. Note that the capture mode is stored as an 308 // |is_capturing_| will be 0 when there are no observers watching the NetLog,
308 // integer rather than a NetLogCaptureMode so that it can be easily 309 // 1 otherwise. Note that this is stored as an Atomic32 rather than a boolean
309 // read/written without a lock using Atomic32. 310 // so it can be accessed without needing a lock.
310 base::subtle::Atomic32 effective_capture_mode_int32_; 311 base::subtle::Atomic32 is_capturing_;
311 312
312 // |lock_| must be acquired whenever reading or writing to this. 313 // |lock_| must be acquired whenever reading or writing to this.
313 ObserverList<ThreadSafeObserver, true> observers_; 314 ObserverList<ThreadSafeObserver, true> observers_;
314 315
315 DISALLOW_COPY_AND_ASSIGN(NetLog); 316 DISALLOW_COPY_AND_ASSIGN(NetLog);
316 }; 317 };
317 318
318 // Helper that binds a Source to a NetLog, and exposes convenience methods to 319 // Helper that binds a Source to a NetLog, and exposes convenience methods to
319 // output log messages without needing to pass in the source. 320 // output log messages without needing to pass in the source.
320 class NET_EXPORT BoundNetLog { 321 class NET_EXPORT BoundNetLog {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // |net_error| must not be ERR_IO_PENDING, as it's not a true error. 356 // |net_error| must not be ERR_IO_PENDING, as it's not a true error.
356 void EndEventWithNetErrorCode(NetLog::EventType event_type, 357 void EndEventWithNetErrorCode(NetLog::EventType event_type,
357 int net_error) const; 358 int net_error) const;
358 359
359 // Logs a byte transfer event to the NetLog. Determines whether to log the 360 // Logs a byte transfer event to the NetLog. Determines whether to log the
360 // received bytes or not based on the current logging level. 361 // received bytes or not based on the current logging level.
361 void AddByteTransferEvent(NetLog::EventType event_type, 362 void AddByteTransferEvent(NetLog::EventType event_type,
362 int byte_count, 363 int byte_count,
363 const char* bytes) const; 364 const char* bytes) const;
364 365
365 NetLogCaptureMode GetCaptureMode() const; 366 bool IsCapturing() const;
366 367
367 // Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care 368 // Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care
368 // of creating a unique source ID, and handles the case of NULL net_log. 369 // of creating a unique source ID, and handles the case of NULL net_log.
369 static BoundNetLog Make(NetLog* net_log, NetLog::SourceType source_type); 370 static BoundNetLog Make(NetLog* net_log, NetLog::SourceType source_type);
370 371
371 const NetLog::Source& source() const { return source_; } 372 const NetLog::Source& source() const { return source_; }
372 NetLog* net_log() const { return net_log_; } 373 NetLog* net_log() const { return net_log_; }
373 374
374 private: 375 private:
375 // TODO(eroman): Temporary until crbug.com/467797 is solved. 376 // TODO(eroman): Temporary until crbug.com/467797 is solved.
(...skipping 11 matching lines...) Expand all
387 NetLog::Source source_; 388 NetLog::Source source_;
388 NetLog* net_log_; 389 NetLog* net_log_;
389 390
390 // TODO(eroman): Temporary until crbug.com/467797 is solved. 391 // TODO(eroman): Temporary until crbug.com/467797 is solved.
391 Liveness liveness_ = ALIVE; 392 Liveness liveness_ = ALIVE;
392 }; 393 };
393 394
394 } // namespace net 395 } // namespace net
395 396
396 #endif // NET_LOG_NET_LOG_H_ 397 #endif // NET_LOG_NET_LOG_H_
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698