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

Side by Side Diff: net/log/write_to_file_net_log_observer.cc

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 <set> 8 #include <set>
9 #include <utility>
10 10
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "net/log/net_log_util.h" 15 #include "net/log/net_log_util.h"
16 #include "net/url_request/url_request_context.h" 16 #include "net/url_request/url_request_context.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 WriteToFileNetLogObserver::WriteToFileNetLogObserver() 20 WriteToFileNetLogObserver::WriteToFileNetLogObserver()
21 : capture_mode_(NetLogCaptureMode::Default()), added_events_(false) { 21 : capture_mode_(NetLogCaptureMode::Default()), added_events_(false) {
22 } 22 }
23 23
24 WriteToFileNetLogObserver::~WriteToFileNetLogObserver() { 24 WriteToFileNetLogObserver::~WriteToFileNetLogObserver() {
25 } 25 }
26 26
27 void WriteToFileNetLogObserver::set_capture_mode( 27 void WriteToFileNetLogObserver::set_capture_mode(
28 NetLogCaptureMode capture_mode) { 28 NetLogCaptureMode capture_mode) {
29 DCHECK(!net_log()); 29 DCHECK(!net_log());
30 capture_mode_ = capture_mode; 30 capture_mode_ = capture_mode;
31 } 31 }
32 32
33 void WriteToFileNetLogObserver::StartObserving( 33 void WriteToFileNetLogObserver::StartObserving(
34 NetLog* net_log, 34 NetLog* net_log,
35 base::ScopedFILE file, 35 base::ScopedFILE file,
36 base::Value* constants, 36 base::Value* constants,
37 URLRequestContext* url_request_context) { 37 URLRequestContext* url_request_context) {
38 DCHECK(file.get()); 38 DCHECK(file.get());
39 file_ = file.Pass(); 39 file_ = std::move(file);
40 added_events_ = false; 40 added_events_ = false;
41 41
42 // Write constants to the output file. This allows loading files that have 42 // Write constants to the output file. This allows loading files that have
43 // different source and event types, as they may be added and removed 43 // different source and event types, as they may be added and removed
44 // between Chrome versions. 44 // between Chrome versions.
45 std::string json; 45 std::string json;
46 if (constants) 46 if (constants)
47 base::JSONWriter::Write(*constants, &json); 47 base::JSONWriter::Write(*constants, &json);
48 else 48 else
49 base::JSONWriter::Write(*GetNetConstants(), &json); 49 base::JSONWriter::Write(*GetNetConstants(), &json);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // so can load partial log files by just ignoring the last line. For this to 91 // so can load partial log files by just ignoring the last line. For this to
92 // work, lines cannot be pretty printed. 92 // work, lines cannot be pretty printed.
93 scoped_ptr<base::Value> value(entry.ToValue()); 93 scoped_ptr<base::Value> value(entry.ToValue());
94 std::string json; 94 std::string json;
95 base::JSONWriter::Write(*value, &json); 95 base::JSONWriter::Write(*value, &json);
96 fprintf(file_.get(), "%s%s", (added_events_ ? ",\n" : ""), json.c_str()); 96 fprintf(file_.get(), "%s%s", (added_events_ ? ",\n" : ""), json.c_str());
97 added_events_ = true; 97 added_events_ = true;
98 } 98 }
99 99
100 } // namespace net 100 } // 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