| OLD | NEW |
| 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_BASE_NET_LOG_H_ | 5 #ifndef NET_BASE_NET_LOG_H_ |
| 6 #define NET_BASE_NET_LOG_H_ | 6 #define NET_BASE_NET_LOG_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "build/build_config.h" |
| 11 |
| 12 // TODO(eroman): Temporary while investigating crbug.com/467797. |
| 13 // Note base::Debug::StackTrace() is not supported in NACL builds |
| 14 // so conditionally disabled it there. |
| 15 #ifndef OS_NACL |
| 16 #define TEMP_INSTRUMENTATION_467797 |
| 17 #endif |
| 18 |
| 10 #include "base/atomicops.h" | 19 #include "base/atomicops.h" |
| 11 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" | 21 #include "base/callback_forward.h" |
| 13 #include "base/compiler_specific.h" | 22 #include "base/compiler_specific.h" |
| 23 #ifdef TEMP_INSTRUMENTATION_467797 |
| 24 #include "base/debug/stack_trace.h" |
| 25 #endif |
| 14 #include "base/observer_list.h" | 26 #include "base/observer_list.h" |
| 15 #include "base/strings/string16.h" | 27 #include "base/strings/string16.h" |
| 16 #include "base/synchronization/lock.h" | 28 #include "base/synchronization/lock.h" |
| 17 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 18 #include "net/base/net_export.h" | 30 #include "net/base/net_export.h" |
| 19 | 31 |
| 20 namespace base { | 32 namespace base { |
| 21 class DictionaryValue; | 33 class DictionaryValue; |
| 22 class Value; | 34 class Value; |
| 23 } | 35 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 ObserverList<ThreadSafeObserver, true> observers_; | 337 ObserverList<ThreadSafeObserver, true> observers_; |
| 326 | 338 |
| 327 DISALLOW_COPY_AND_ASSIGN(NetLog); | 339 DISALLOW_COPY_AND_ASSIGN(NetLog); |
| 328 }; | 340 }; |
| 329 | 341 |
| 330 // Helper that binds a Source to a NetLog, and exposes convenience methods to | 342 // Helper that binds a Source to a NetLog, and exposes convenience methods to |
| 331 // output log messages without needing to pass in the source. | 343 // output log messages without needing to pass in the source. |
| 332 class NET_EXPORT BoundNetLog { | 344 class NET_EXPORT BoundNetLog { |
| 333 public: | 345 public: |
| 334 BoundNetLog() : net_log_(NULL) {} | 346 BoundNetLog() : net_log_(NULL) {} |
| 347 ~BoundNetLog(); |
| 335 | 348 |
| 336 // Add a log entry to the NetLog for the bound source. | 349 // Add a log entry to the NetLog for the bound source. |
| 337 void AddEntry(NetLog::EventType type, NetLog::EventPhase phase) const; | 350 void AddEntry(NetLog::EventType type, NetLog::EventPhase phase) const; |
| 338 void AddEntry(NetLog::EventType type, | 351 void AddEntry(NetLog::EventType type, |
| 339 NetLog::EventPhase phase, | 352 NetLog::EventPhase phase, |
| 340 const NetLog::ParametersCallback& get_parameters) const; | 353 const NetLog::ParametersCallback& get_parameters) const; |
| 341 | 354 |
| 342 // Convenience methods that call AddEntry with a fixed "capture phase" | 355 // Convenience methods that call AddEntry with a fixed "capture phase" |
| 343 // (begin, end, or none). | 356 // (begin, end, or none). |
| 344 void BeginEvent(NetLog::EventType type) const; | 357 void BeginEvent(NetLog::EventType type) const; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 bool IsLogging() const; | 394 bool IsLogging() const; |
| 382 | 395 |
| 383 // Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care | 396 // Helper to create a BoundNetLog given a NetLog and a SourceType. Takes care |
| 384 // of creating a unique source ID, and handles the case of NULL net_log. | 397 // of creating a unique source ID, and handles the case of NULL net_log. |
| 385 static BoundNetLog Make(NetLog* net_log, NetLog::SourceType source_type); | 398 static BoundNetLog Make(NetLog* net_log, NetLog::SourceType source_type); |
| 386 | 399 |
| 387 const NetLog::Source& source() const { return source_; } | 400 const NetLog::Source& source() const { return source_; } |
| 388 NetLog* net_log() const { return net_log_; } | 401 NetLog* net_log() const { return net_log_; } |
| 389 | 402 |
| 390 private: | 403 private: |
| 404 #ifdef TEMP_INSTRUMENTATION_467797 |
| 405 // TODO(eroman): Temporary while investigating crbug.com/467797 |
| 406 enum Liveness { |
| 407 ALIVE = 0xCA11AB13, |
| 408 DEAD = 0xDEADBEEF, |
| 409 }; |
| 410 #endif |
| 411 |
| 391 BoundNetLog(const NetLog::Source& source, NetLog* net_log) | 412 BoundNetLog(const NetLog::Source& source, NetLog* net_log) |
| 392 : source_(source), net_log_(net_log) { | 413 : source_(source), net_log_(net_log) { |
| 393 } | 414 } |
| 394 | 415 |
| 416 // TODO(eroman): Temporary while investigating crbug.com/467797 |
| 417 void CrashIfInvalid() const; |
| 418 |
| 395 NetLog::Source source_; | 419 NetLog::Source source_; |
| 396 NetLog* net_log_; | 420 NetLog* net_log_; |
| 421 |
| 422 #ifdef TEMP_INSTRUMENTATION_467797 |
| 423 // TODO(eroman): Temporary while investigating crbug.com/467797 |
| 424 Liveness liveness_ = ALIVE; |
| 425 base::debug::StackTrace stack_trace_; |
| 426 #endif |
| 397 }; | 427 }; |
| 398 | 428 |
| 399 } // namespace net | 429 } // namespace net |
| 400 | 430 |
| 401 #endif // NET_BASE_NET_LOG_H_ | 431 #endif // NET_BASE_NET_LOG_H_ |
| OLD | NEW |