OLD | NEW |
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 | 9 |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/files/scoped_file.h" | 12 #include "base/files/scoped_file.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
14 #include "net/log/net_log_util.h" | 15 #include "net/log/net_log_util.h" |
15 #include "net/log/write_to_file_net_log_observer.h" | 16 #include "net/log/write_to_file_net_log_observer.h" |
16 | 17 |
17 namespace chromecast { | 18 namespace chromecast { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // performance is not a big concern. | 54 // performance is not a big concern. |
54 base::ScopedFILE file; | 55 base::ScopedFILE file; |
55 file.reset(fopen(log_path.value().c_str(), "w")); | 56 file.reset(fopen(log_path.value().c_str(), "w")); |
56 | 57 |
57 if (!file) { | 58 if (!file) { |
58 LOG(ERROR) << "Could not open file " << log_path.value() | 59 LOG(ERROR) << "Could not open file " << log_path.value() |
59 << " for net logging"; | 60 << " for net logging"; |
60 } else { | 61 } else { |
61 scoped_ptr<base::Value> constants(GetShellConstants()); | 62 scoped_ptr<base::Value> constants(GetShellConstants()); |
62 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); | 63 write_to_file_observer_.reset(new net::WriteToFileNetLogObserver()); |
63 write_to_file_observer_->StartObserving(this, file.Pass(), | 64 write_to_file_observer_->StartObserving(this, std::move(file), |
64 constants.get(), nullptr); | 65 constants.get(), nullptr); |
65 } | 66 } |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
69 CastNetLog::~CastNetLog() { | 70 CastNetLog::~CastNetLog() { |
70 // Remove the observer we own before we're destroyed. | 71 // Remove the observer we own before we're destroyed. |
71 if (write_to_file_observer_) | 72 if (write_to_file_observer_) |
72 write_to_file_observer_->StopObserving(nullptr); | 73 write_to_file_observer_->StopObserving(nullptr); |
73 } | 74 } |
74 | 75 |
75 } // namespace chromecast | 76 } // namespace chromecast |
OLD | NEW |