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

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

Issue 1135373002: Updated NetLog::ParametersCallback & all related calbacks returning value as scoped_ptr<base::Value… Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_stream_parser.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"
11 11
12 #include "base/atomicops.h" 12 #include "base/atomicops.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback_forward.h" 14 #include "base/callback_forward.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "base/values.h"
20 #include "net/base/net_export.h" 21 #include "net/base/net_export.h"
21 #include "net/log/net_log_capture_mode.h" 22 #include "net/log/net_log_capture_mode.h"
22 23
23 namespace base { 24 namespace base {
24 class DictionaryValue; 25 class DictionaryValue;
25 class Value; 26 class Value;
26 } 27 }
27 28
28 namespace net { 29 namespace net {
29 30
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #define SOURCE_TYPE(label) SOURCE_##label, 65 #define SOURCE_TYPE(label) SOURCE_##label,
65 #include "net/log/net_log_source_type_list.h" 66 #include "net/log/net_log_source_type_list.h"
66 #undef SOURCE_TYPE 67 #undef SOURCE_TYPE
67 SOURCE_COUNT 68 SOURCE_COUNT
68 }; 69 };
69 70
70 // A callback function that return a Value representation of the parameters 71 // A callback function that return a Value representation of the parameters
71 // associated with an event. If called, it will be called synchonously, 72 // associated with an event. If called, it will be called synchonously,
72 // so it need not have owning references. May be called more than once, or 73 // so it need not have owning references. May be called more than once, or
73 // not at all. May return NULL. 74 // not at all. May return NULL.
74 typedef base::Callback<base::Value*(NetLogCaptureMode)> ParametersCallback; 75 typedef base::Callback<scoped_ptr<base::Value>(NetLogCaptureMode)>
76 ParametersCallback;
75 77
76 // Identifies the entity that generated this log. The |id| field should 78 // Identifies the entity that generated this log. The |id| field should
77 // uniquely identify the source, and is used by log observers to infer 79 // uniquely identify the source, and is used by log observers to infer
78 // message groupings. Can use NetLog::NextID() to create unique IDs. 80 // message groupings. Can use NetLog::NextID() to create unique IDs.
79 struct NET_EXPORT Source { 81 struct NET_EXPORT Source {
80 static const uint32 kInvalidId; 82 static const uint32 kInvalidId;
81 83
82 Source(); 84 Source();
83 Source(SourceType type, uint32 id); 85 Source(SourceType type, uint32 id);
84 bool IsValid() const; 86 bool IsValid() const;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 Entry(const EntryData* data, NetLogCaptureMode capture_mode); 126 Entry(const EntryData* data, NetLogCaptureMode capture_mode);
125 ~Entry(); 127 ~Entry();
126 128
127 EventType type() const { return data_->type; } 129 EventType type() const { return data_->type; }
128 Source source() const { return data_->source; } 130 Source source() const { return data_->source; }
129 EventPhase phase() const { return data_->phase; } 131 EventPhase phase() const { return data_->phase; }
130 132
131 // Serializes the specified event to a Value. The Value also includes the 133 // Serializes the specified event to a Value. The Value also includes the
132 // current time. Caller takes ownership of returned Value. Takes in a time 134 // current time. Caller takes ownership of returned Value. Takes in a time
133 // to allow back-dating entries. 135 // to allow back-dating entries.
134 base::Value* ToValue() const; 136 scoped_ptr<base::Value> ToValue() const;
135 137
136 // Returns the parameters as a Value. Returns NULL if there are no 138 // Returns the parameters as a Value. Returns NULL if there are no
137 // parameters. Caller takes ownership of returned Value. 139 // parameters. Caller takes ownership of returned Value.
138 base::Value* ParametersToValue() const; 140 scoped_ptr<base::Value> ParametersToValue() const;
139 141
140 private: 142 private:
141 const EntryData* const data_; 143 const EntryData* const data_;
142 144
143 // Log capture mode when the event occurred. 145 // Log capture mode when the event occurred.
144 const NetLogCaptureMode capture_mode_; 146 const NetLogCaptureMode capture_mode_;
145 147
146 // It is not safe to copy this class, since |parameters_callback_| may 148 // It is not safe to copy this class, since |parameters_callback_| may
147 // include pointers that become stale immediately after the event is added, 149 // include pointers that become stale immediately after the event is added,
148 // even if the code were modified to keep its own copy of the callback. 150 // even if the code were modified to keep its own copy of the callback.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 NetLog::Source source_; 390 NetLog::Source source_;
389 NetLog* net_log_; 391 NetLog* net_log_;
390 392
391 // TODO(eroman): Temporary until crbug.com/467797 is solved. 393 // TODO(eroman): Temporary until crbug.com/467797 is solved.
392 Liveness liveness_ = ALIVE; 394 Liveness liveness_ = ALIVE;
393 }; 395 };
394 396
395 } // namespace net 397 } // namespace net
396 398
397 #endif // NET_LOG_NET_LOG_H_ 399 #endif // NET_LOG_NET_LOG_H_
OLDNEW
« no previous file with comments | « net/http/http_stream_parser.cc ('k') | net/log/net_log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698