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

Side by Side Diff: net/tools/gdig/file_net_log.cc

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 years, 8 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/tools/flip_server/spdy_interface_test.cc ('k') | net/tools/gdig/gdig.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 #include "net/tools/gdig/file_net_log.h"
6
5 #include <stdio.h> 7 #include <stdio.h>
6 8
9 #include <memory>
10
7 #include "base/json/json_string_value_serializer.h" 11 #include "base/json/json_string_value_serializer.h"
8 #include "base/logging.h" 12 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 13 #include "base/values.h"
11 #include "net/tools/gdig/file_net_log.h"
12 14
13 namespace net { 15 namespace net {
14 16
15 FileNetLogObserver::FileNetLogObserver(FILE* destination) 17 FileNetLogObserver::FileNetLogObserver(FILE* destination)
16 : destination_(destination) { 18 : destination_(destination) {
17 DCHECK(destination != NULL); 19 DCHECK(destination != NULL);
18 } 20 }
19 21
20 FileNetLogObserver::~FileNetLogObserver() { 22 FileNetLogObserver::~FileNetLogObserver() {
21 } 23 }
22 24
23 void FileNetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { 25 void FileNetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) {
24 // Only BoundNetLogs without a NetLog should have an invalid source. 26 // Only BoundNetLogs without a NetLog should have an invalid source.
25 DCHECK(entry.source().IsValid()); 27 DCHECK(entry.source().IsValid());
26 28
27 const char* source = NetLog::SourceTypeToString(entry.source().type); 29 const char* source = NetLog::SourceTypeToString(entry.source().type);
28 const char* type = NetLog::EventTypeToString(entry.type()); 30 const char* type = NetLog::EventTypeToString(entry.type());
29 31
30 scoped_ptr<base::Value> param_value(entry.ParametersToValue()); 32 std::unique_ptr<base::Value> param_value(entry.ParametersToValue());
31 std::string params; 33 std::string params;
32 if (param_value.get() != NULL) { 34 if (param_value.get() != NULL) {
33 JSONStringValueSerializer serializer(&params); 35 JSONStringValueSerializer serializer(&params);
34 bool ret = serializer.Serialize(*param_value); 36 bool ret = serializer.Serialize(*param_value);
35 DCHECK(ret); 37 DCHECK(ret);
36 } 38 }
37 base::Time now = base::Time::NowFromSystemTime(); 39 base::Time now = base::Time::NowFromSystemTime();
38 base::AutoLock lock(lock_); 40 base::AutoLock lock(lock_);
39 if (first_event_time_.is_null()) { 41 if (first_event_time_.is_null()) {
40 first_event_time_ = now; 42 first_event_time_ = now;
41 } 43 }
42 base::TimeDelta elapsed_time = now - first_event_time_; 44 base::TimeDelta elapsed_time = now - first_event_time_;
43 fprintf(destination_ , "%u\t%u\t%s\t%s\t%s\n", 45 fprintf(destination_ , "%u\t%u\t%s\t%s\t%s\n",
44 static_cast<unsigned>(elapsed_time.InMilliseconds()), 46 static_cast<unsigned>(elapsed_time.InMilliseconds()),
45 entry.source().id, source, type, params.c_str()); 47 entry.source().id, source, type, params.c_str());
46 } 48 }
47 49
48 } // namespace net 50 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/flip_server/spdy_interface_test.cc ('k') | net/tools/gdig/gdig.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698