| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
| 121 if (state_ != STATE_ALLOW_START_SEND) | 121 if (state_ != STATE_ALLOW_START_SEND) |
| 122 return false; | 122 return false; |
| 123 | 123 |
| 124 if (!NetExportLogExists()) | 124 if (!NetExportLogExists()) |
| 125 return false; | 125 return false; |
| 126 | 126 |
| 127 DCHECK(!log_path_.empty()); | 127 DCHECK(!log_path_.empty()); |
| 128 #if defined(OS_POSIX) | 128 #if defined(OS_POSIX) |
| 129 // Users, group and others can read, write and traverse. | 129 // Users, group and others can read, write and traverse. |
| 130 int mode = file_util::FILE_PERMISSION_MASK; | 130 int mode = base::FILE_PERMISSION_MASK; |
| 131 file_util::SetPosixFilePermissions(log_path_, mode); | 131 base::SetPosixFilePermissions(log_path_, mode); |
| 132 #endif // defined(OS_POSIX) | 132 #endif // defined(OS_POSIX) |
| 133 | 133 |
| 134 *path = log_path_; | 134 *path = log_path_; |
| 135 return true; | 135 return true; |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool NetLogTempFile::GetNetExportLog() { | 138 bool NetLogTempFile::GetNetExportLog() { |
| 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); |
| 140 base::FilePath temp_dir; | 140 base::FilePath temp_dir; |
| 141 if (!GetNetExportLogDirectory(&temp_dir)) | 141 if (!GetNetExportLogDirectory(&temp_dir)) |
| 142 return false; | 142 return false; |
| 143 | 143 |
| 144 log_path_ = temp_dir.Append(log_filename_); | 144 log_path_ = temp_dir.Append(log_filename_); |
| 145 return true; | 145 return true; |
| 146 } | 146 } |
| 147 | 147 |
| 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 file_util::GetTempDir(path); | 150 return file_util::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 |