| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 uint32 id; | 71 uint32 id; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // Base class for associating additional parameters with an event. Log | 74 // Base class for associating additional parameters with an event. Log |
| 75 // observers need to know what specific derivations of EventParameters a | 75 // observers need to know what specific derivations of EventParameters a |
| 76 // particular EventType uses, in order to get at the individual components. | 76 // particular EventType uses, in order to get at the individual components. |
| 77 class NET_EXPORT EventParameters | 77 class NET_EXPORT EventParameters |
| 78 : public base::RefCountedThreadSafe<EventParameters> { | 78 : public base::RefCountedThreadSafe<EventParameters> { |
| 79 public: | 79 public: |
| 80 EventParameters() {} | 80 EventParameters() {} |
| 81 virtual ~EventParameters() {} | |
| 82 | 81 |
| 83 // Serializes the parameters to a Value tree. This is intended to be a | 82 // Serializes the parameters to a Value tree. This is intended to be a |
| 84 // lossless conversion, which is used to serialize the parameters to JSON. | 83 // lossless conversion, which is used to serialize the parameters to JSON. |
| 85 // The caller takes ownership of the returned Value*. | 84 // The caller takes ownership of the returned Value*. |
| 86 virtual base::Value* ToValue() const = 0; | 85 virtual base::Value* ToValue() const = 0; |
| 87 | 86 |
| 87 protected: |
| 88 virtual ~EventParameters() {} |
| 89 |
| 88 private: | 90 private: |
| 91 friend class base::RefCountedThreadSafe<EventParameters>; |
| 92 |
| 89 DISALLOW_COPY_AND_ASSIGN(EventParameters); | 93 DISALLOW_COPY_AND_ASSIGN(EventParameters); |
| 90 }; | 94 }; |
| 91 | 95 |
| 92 // Specifies the granularity of events that should be emitted to the log. | 96 // Specifies the granularity of events that should be emitted to the log. |
| 93 enum LogLevel { | 97 enum LogLevel { |
| 94 // Log everything possible, even if it is slow and memory expensive. | 98 // Log everything possible, even if it is slow and memory expensive. |
| 95 // Includes logging of transferred bytes. | 99 // Includes logging of transferred bytes. |
| 96 LOG_ALL, | 100 LOG_ALL, |
| 97 | 101 |
| 98 // Log all events, but do not include the actual transferred bytes as | 102 // Log all events, but do not include the actual transferred bytes as |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 NetLog::Source source_; | 318 NetLog::Source source_; |
| 315 NetLog* net_log_; | 319 NetLog* net_log_; |
| 316 }; | 320 }; |
| 317 | 321 |
| 318 // NetLogStringParameter is a subclass of EventParameters that encapsulates a | 322 // NetLogStringParameter is a subclass of EventParameters that encapsulates a |
| 319 // single std::string parameter. | 323 // single std::string parameter. |
| 320 class NET_EXPORT NetLogStringParameter : public NetLog::EventParameters { | 324 class NET_EXPORT NetLogStringParameter : public NetLog::EventParameters { |
| 321 public: | 325 public: |
| 322 // |name| must be a string literal. | 326 // |name| must be a string literal. |
| 323 NetLogStringParameter(const char* name, const std::string& value); | 327 NetLogStringParameter(const char* name, const std::string& value); |
| 324 virtual ~NetLogStringParameter(); | |
| 325 | 328 |
| 326 const std::string& value() const { | 329 const std::string& value() const { |
| 327 return value_; | 330 return value_; |
| 328 } | 331 } |
| 329 | 332 |
| 330 virtual base::Value* ToValue() const OVERRIDE; | 333 virtual base::Value* ToValue() const OVERRIDE; |
| 331 | 334 |
| 335 protected: |
| 336 virtual ~NetLogStringParameter(); |
| 337 |
| 332 private: | 338 private: |
| 333 const char* const name_; | 339 const char* const name_; |
| 334 const std::string value_; | 340 const std::string value_; |
| 335 }; | 341 }; |
| 336 | 342 |
| 337 // NetLogIntegerParameter is a subclass of EventParameters that encapsulates a | 343 // NetLogIntegerParameter is a subclass of EventParameters that encapsulates a |
| 338 // single integer parameter. | 344 // single integer parameter. |
| 339 class NET_EXPORT NetLogIntegerParameter : public NetLog::EventParameters { | 345 class NET_EXPORT NetLogIntegerParameter : public NetLog::EventParameters { |
| 340 public: | 346 public: |
| 341 // |name| must be a string literal. | 347 // |name| must be a string literal. |
| 342 NetLogIntegerParameter(const char* name, int value) | 348 NetLogIntegerParameter(const char* name, int value) |
| 343 : name_(name), value_(value) {} | 349 : name_(name), value_(value) {} |
| 344 | 350 |
| 345 int value() const { | 351 int value() const { |
| 346 return value_; | 352 return value_; |
| 347 } | 353 } |
| 348 | 354 |
| 349 virtual base::Value* ToValue() const OVERRIDE; | 355 virtual base::Value* ToValue() const OVERRIDE; |
| 350 | 356 |
| 357 protected: |
| 358 virtual ~NetLogIntegerParameter() {} |
| 359 |
| 351 private: | 360 private: |
| 352 const char* name_; | 361 const char* name_; |
| 353 const int value_; | 362 const int value_; |
| 354 }; | 363 }; |
| 355 | 364 |
| 356 // NetLogSourceParameter is a subclass of EventParameters that encapsulates a | 365 // NetLogSourceParameter is a subclass of EventParameters that encapsulates a |
| 357 // single NetLog::Source parameter. | 366 // single NetLog::Source parameter. |
| 358 class NET_EXPORT NetLogSourceParameter : public NetLog::EventParameters { | 367 class NET_EXPORT NetLogSourceParameter : public NetLog::EventParameters { |
| 359 public: | 368 public: |
| 360 // |name| must be a string literal. | 369 // |name| must be a string literal. |
| 361 NetLogSourceParameter(const char* name, const NetLog::Source& value) | 370 NetLogSourceParameter(const char* name, const NetLog::Source& value) |
| 362 : name_(name), value_(value) {} | 371 : name_(name), value_(value) {} |
| 363 | 372 |
| 364 const NetLog::Source& value() const { | 373 const NetLog::Source& value() const { |
| 365 return value_; | 374 return value_; |
| 366 } | 375 } |
| 367 | 376 |
| 368 virtual base::Value* ToValue() const OVERRIDE; | 377 virtual base::Value* ToValue() const OVERRIDE; |
| 369 | 378 |
| 379 protected: |
| 380 virtual ~NetLogSourceParameter() {} |
| 381 |
| 370 private: | 382 private: |
| 371 const char* name_; | 383 const char* name_; |
| 372 const NetLog::Source value_; | 384 const NetLog::Source value_; |
| 373 }; | 385 }; |
| 374 | 386 |
| 375 // ScopedNetLogEvent logs a begin event on creation, and the corresponding end | 387 // ScopedNetLogEvent logs a begin event on creation, and the corresponding end |
| 376 // event on destruction. | 388 // event on destruction. |
| 377 class NET_EXPORT_PRIVATE ScopedNetLogEvent { | 389 class NET_EXPORT_PRIVATE ScopedNetLogEvent { |
| 378 public: | 390 public: |
| 379 ScopedNetLogEvent(const BoundNetLog& net_log, | 391 ScopedNetLogEvent(const BoundNetLog& net_log, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 392 | 404 |
| 393 private: | 405 private: |
| 394 BoundNetLog net_log_; | 406 BoundNetLog net_log_; |
| 395 const NetLog::EventType event_type_; | 407 const NetLog::EventType event_type_; |
| 396 scoped_refptr<NetLog::EventParameters> end_event_params_; | 408 scoped_refptr<NetLog::EventParameters> end_event_params_; |
| 397 }; | 409 }; |
| 398 | 410 |
| 399 } // namespace net | 411 } // namespace net |
| 400 | 412 |
| 401 #endif // NET_BASE_NET_LOG_H_ | 413 #endif // NET_BASE_NET_LOG_H_ |
| OLD | NEW |