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

Side by Side Diff: chromecast/browser/cast_net_log.cc

Issue 1875623002: Convert //chromecast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chromecast/browser/cast_net_log.h" 5 #include "chromecast/browser/cast_net_log.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/scoped_file.h" 12 #include "base/files/scoped_file.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "content/public/common/content_switches.h" 14 #include "content/public/common/content_switches.h"
15 #include "net/log/net_log_util.h" 15 #include "net/log/net_log_util.h"
16 #include "net/log/write_to_file_net_log_observer.h" 16 #include "net/log/write_to_file_net_log_observer.h"
17 17
18 namespace chromecast { 18 namespace chromecast {
19 19
20 namespace { 20 namespace {
21 21
22 base::DictionaryValue* GetShellConstants() { 22 base::DictionaryValue* GetShellConstants() {
23 scoped_ptr<base::DictionaryValue> constants_dict = net::GetNetConstants(); 23 std::unique_ptr<base::DictionaryValue> constants_dict =
24 net::GetNetConstants();
24 25
25 // Add a dictionary with client information 26 // Add a dictionary with client information
26 base::DictionaryValue* dict = new base::DictionaryValue(); 27 base::DictionaryValue* dict = new base::DictionaryValue();
27 28
28 dict->SetString("name", "cast_shell"); 29 dict->SetString("name", "cast_shell");
29 dict->SetString( 30 dict->SetString(
30 "command_line", 31 "command_line",
31 base::CommandLine::ForCurrentProcess()->GetCommandLineString()); 32 base::CommandLine::ForCurrentProcess()->GetCommandLineString());
32 33
33 constants_dict->Set("clientInfo", dict); 34 constants_dict->Set("clientInfo", dict);
(...skipping 18 matching lines...) Expand all
52 // would result in an unbounded buffer size, so not much can be gained by 53 // would result in an unbounded buffer size, so not much can be gained by
53 // doing this on another thread. It's only used when debugging, so 54 // doing this on another thread. It's only used when debugging, so
54 // performance is not a big concern. 55 // performance is not a big concern.
55 base::ScopedFILE file; 56 base::ScopedFILE file;
56 file.reset(fopen(log_path.value().c_str(), "w")); 57 file.reset(fopen(log_path.value().c_str(), "w"));
57 58
58 if (!file) { 59 if (!file) {
59 LOG(ERROR) << "Could not open file " << log_path.value() 60 LOG(ERROR) << "Could not open file " << log_path.value()
60 << " for net logging"; 61 << " for net logging";
61 } else { 62 } else {
62 scoped_ptr<base::Value> constants(GetShellConstants()); 63 std::unique_ptr<base::Value> constants(GetShellConstants());
63 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); 64 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver());
64 write_to_file_observer_->StartObserving(this, std::move(file), 65 write_to_file_observer_->StartObserving(this, std::move(file),
65 constants.get(), nullptr); 66 constants.get(), nullptr);
66 } 67 }
67 } 68 }
68 } 69 }
69 70
70 CastNetLog::~CastNetLog() { 71 CastNetLog::~CastNetLog() {
71 // Remove the observer we own before we're destroyed. 72 // Remove the observer we own before we're destroyed.
72 if (write_to_file_observer_) 73 if (write_to_file_observer_)
73 write_to_file_observer_->StopObserving(nullptr); 74 write_to_file_observer_->StopObserving(nullptr);
74 } 75 }
75 76
76 } // namespace chromecast 77 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/cast_net_log.h ('k') | chromecast/browser/devtools/remote_debugging_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698