| 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_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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "build/build_config.h" | |
| 13 | |
| 14 #include "base/atomicops.h" | 13 #include "base/atomicops.h" |
| 15 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 16 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 17 #include "base/macros.h" | 16 #include "base/macros.h" |
| 18 #include "base/memory/scoped_ptr.h" | |
| 19 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 20 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
| 21 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
| 22 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "build/build_config.h" |
| 23 #include "net/base/net_export.h" | 22 #include "net/base/net_export.h" |
| 24 #include "net/log/net_log_capture_mode.h" | 23 #include "net/log/net_log_capture_mode.h" |
| 25 | 24 |
| 26 namespace base { | 25 namespace base { |
| 27 class DictionaryValue; | 26 class DictionaryValue; |
| 28 class Value; | 27 class Value; |
| 29 } | 28 } |
| 30 | 29 |
| 31 namespace net { | 30 namespace net { |
| 32 | 31 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 #define SOURCE_TYPE(label) SOURCE_##label, | 66 #define SOURCE_TYPE(label) SOURCE_##label, |
| 68 #include "net/log/net_log_source_type_list.h" | 67 #include "net/log/net_log_source_type_list.h" |
| 69 #undef SOURCE_TYPE | 68 #undef SOURCE_TYPE |
| 70 SOURCE_COUNT | 69 SOURCE_COUNT |
| 71 }; | 70 }; |
| 72 | 71 |
| 73 // A callback that returns a Value representation of the parameters | 72 // A callback that returns a Value representation of the parameters |
| 74 // associated with an event. If called, it will be called synchronously, | 73 // associated with an event. If called, it will be called synchronously, |
| 75 // so it need not have owning references. May be called more than once, or | 74 // so it need not have owning references. May be called more than once, or |
| 76 // not at all. May return NULL. | 75 // not at all. May return NULL. |
| 77 typedef base::Callback<scoped_ptr<base::Value>(NetLogCaptureMode)> | 76 typedef base::Callback<std::unique_ptr<base::Value>(NetLogCaptureMode)> |
| 78 ParametersCallback; | 77 ParametersCallback; |
| 79 | 78 |
| 80 // Identifies the entity that generated this log. The |id| field should | 79 // Identifies the entity that generated this log. The |id| field should |
| 81 // uniquely identify the source, and is used by log observers to infer | 80 // uniquely identify the source, and is used by log observers to infer |
| 82 // message groupings. Can use NetLog::NextID() to create unique IDs. | 81 // message groupings. Can use NetLog::NextID() to create unique IDs. |
| 83 struct NET_EXPORT Source { | 82 struct NET_EXPORT Source { |
| 84 static const uint32_t kInvalidId; | 83 static const uint32_t kInvalidId; |
| 85 | 84 |
| 86 Source(); | 85 Source(); |
| 87 Source(SourceType type, uint32_t id); | 86 Source(SourceType type, uint32_t id); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 Source source() const { return data_->source; } | 131 Source source() const { return data_->source; } |
| 133 EventPhase phase() const { return data_->phase; } | 132 EventPhase phase() const { return data_->phase; } |
| 134 | 133 |
| 135 // Serializes the specified event to a Value. The Value also includes the | 134 // Serializes the specified event to a Value. The Value also includes the |
| 136 // current time. Caller takes ownership of returned Value. Takes in a time | 135 // current time. Caller takes ownership of returned Value. Takes in a time |
| 137 // to allow back-dating entries. | 136 // to allow back-dating entries. |
| 138 base::Value* ToValue() const; | 137 base::Value* ToValue() const; |
| 139 | 138 |
| 140 // Returns the parameters as a Value. Returns NULL if there are no | 139 // Returns the parameters as a Value. Returns NULL if there are no |
| 141 // parameters. Caller takes ownership of returned Value. | 140 // parameters. Caller takes ownership of returned Value. |
| 142 scoped_ptr<base::Value> ParametersToValue() const; | 141 std::unique_ptr<base::Value> ParametersToValue() const; |
| 143 | 142 |
| 144 private: | 143 private: |
| 145 const EntryData* const data_; | 144 const EntryData* const data_; |
| 146 | 145 |
| 147 // Log capture mode when the event occurred. | 146 // Log capture mode when the event occurred. |
| 148 const NetLogCaptureMode capture_mode_; | 147 const NetLogCaptureMode capture_mode_; |
| 149 | 148 |
| 150 // It is not safe to copy this class, since |parameters_callback_| may | 149 // It is not safe to copy this class, since |parameters_callback_| may |
| 151 // include pointers that become stale immediately after the event is added, | 150 // include pointers that become stale immediately after the event is added, |
| 152 // even if the code were modified to keep its own copy of the callback. | 151 // even if the code were modified to keep its own copy of the callback. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 NetLog::Source source_; | 386 NetLog::Source source_; |
| 388 NetLog* net_log_; | 387 NetLog* net_log_; |
| 389 | 388 |
| 390 // TODO(eroman): Temporary until crbug.com/467797 is solved. | 389 // TODO(eroman): Temporary until crbug.com/467797 is solved. |
| 391 Liveness liveness_ = ALIVE; | 390 Liveness liveness_ = ALIVE; |
| 392 }; | 391 }; |
| 393 | 392 |
| 394 } // namespace net | 393 } // namespace net |
| 395 | 394 |
| 396 #endif // NET_LOG_NET_LOG_H_ | 395 #endif // NET_LOG_NET_LOG_H_ |
| OLD | NEW |