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

Side by Side Diff: net/log/write_to_file_net_log_observer.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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/log/write_to_file_net_log_observer.h" 5 #include "net/log/write_to_file_net_log_observer.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8
9 #include <memory>
8 #include <set> 10 #include <set>
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "net/log/net_log_util.h" 16 #include "net/log/net_log_util.h"
16 #include "net/url_request/url_request_context.h" 17 #include "net/url_request/url_request_context.h"
17 18
18 namespace net { 19 namespace net {
19 20
20 WriteToFileNetLogObserver::WriteToFileNetLogObserver() 21 WriteToFileNetLogObserver::WriteToFileNetLogObserver()
21 : capture_mode_(NetLogCaptureMode::Default()), added_events_(false) { 22 : capture_mode_(NetLogCaptureMode::Default()), added_events_(false) {
22 } 23 }
23 24
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 84 }
84 fprintf(file_.get(), "}"); 85 fprintf(file_.get(), "}");
85 86
86 file_.reset(); 87 file_.reset();
87 } 88 }
88 89
89 void WriteToFileNetLogObserver::OnAddEntry(const NetLog::Entry& entry) { 90 void WriteToFileNetLogObserver::OnAddEntry(const NetLog::Entry& entry) {
90 // Add a comma and newline for every event but the first. Newlines are needed 91 // Add a comma and newline for every event but the first. Newlines are needed
91 // so can load partial log files by just ignoring the last line. For this to 92 // so can load partial log files by just ignoring the last line. For this to
92 // work, lines cannot be pretty printed. 93 // work, lines cannot be pretty printed.
93 scoped_ptr<base::Value> value(entry.ToValue()); 94 std::unique_ptr<base::Value> value(entry.ToValue());
94 std::string json; 95 std::string json;
95 base::JSONWriter::Write(*value, &json); 96 base::JSONWriter::Write(*value, &json);
96 fprintf(file_.get(), "%s%s", (added_events_ ? ",\n" : ""), json.c_str()); 97 fprintf(file_.get(), "%s%s", (added_events_ ? ",\n" : ""), json.c_str());
97 added_events_ = true; 98 added_events_ = true;
98 } 99 }
99 100
100 } // namespace net 101 } // namespace net
OLDNEW
« no previous file with comments | « net/log/trace_net_log_observer_unittest.cc ('k') | net/log/write_to_file_net_log_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698