OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/net/net_log_temp_file.h" | 5 #include "chrome/browser/net/net_log_temp_file.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/net/chrome_net_log.h" | 9 #include "chrome/browser/net/chrome_net_log.h" |
10 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" | 10 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 89 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
90 if (state_ == STATE_ALLOW_STOP) | 90 if (state_ == STATE_ALLOW_STOP) |
91 return; | 91 return; |
92 | 92 |
93 DCHECK_NE(STATE_UNINITIALIZED, state_); | 93 DCHECK_NE(STATE_UNINITIALIZED, state_); |
94 DCHECK(!log_path_.empty()); | 94 DCHECK(!log_path_.empty()); |
95 | 95 |
96 // Try to make sure we can create the file. | 96 // Try to make sure we can create the file. |
97 // TODO(rtenneti): Find a better for doing the following. Surface some error | 97 // TODO(rtenneti): Find a better for doing the following. Surface some error |
98 // to the user if we couldn't create the file. | 98 // to the user if we couldn't create the file. |
99 FILE* file = base::OpenFile(log_path_, "w"); | 99 FILE* file = file_util::OpenFile(log_path_, "w"); |
100 if (file == NULL) | 100 if (file == NULL) |
101 return; | 101 return; |
102 | 102 |
103 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); | 103 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); |
104 net_log_logger_.reset(new net::NetLogLogger(file, *constants)); | 104 net_log_logger_.reset(new net::NetLogLogger(file, *constants)); |
105 net_log_logger_->StartObserving(chrome_net_log_); | 105 net_log_logger_->StartObserving(chrome_net_log_); |
106 state_ = STATE_ALLOW_STOP; | 106 state_ = STATE_ALLOW_STOP; |
107 } | 107 } |
108 | 108 |
109 void NetLogTempFile::StopNetLog() { | 109 void NetLogTempFile::StopNetLog() { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 bool NetLogTempFile::GetNetExportLogDirectory(base::FilePath* path) { | 148 bool NetLogTempFile::GetNetExportLogDirectory(base::FilePath* path) { |
149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 149 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
150 return base::GetTempDir(path); | 150 return base::GetTempDir(path); |
151 } | 151 } |
152 | 152 |
153 bool NetLogTempFile::NetExportLogExists() { | 153 bool NetLogTempFile::NetExportLogExists() { |
154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
155 DCHECK(!log_path_.empty()); | 155 DCHECK(!log_path_.empty()); |
156 return base::PathExists(log_path_); | 156 return base::PathExists(log_path_); |
157 } | 157 } |
OLD | NEW |