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

Side by Side Diff: chrome/browser/net/net_log_temp_file.cc

Issue 976483002: Add ability for NetLogLogger to gather data from more than just NetLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments Created 5 years, 9 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 (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/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_file.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 #include "chrome/browser/net/chrome_net_log.h" 10 #include "chrome/browser/net/chrome_net_log.h"
10 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" 11 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
11 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
12 #include "net/base/net_log_logger.h" 13 #include "net/base/net_log_logger.h"
13 14
14 using content::BrowserThread; 15 using content::BrowserThread;
15 16
16 NetLogTempFile::NetLogTempFile(ChromeNetLog* chrome_net_log) 17 NetLogTempFile::NetLogTempFile(ChromeNetLog* chrome_net_log)
17 : state_(STATE_UNINITIALIZED), 18 : state_(STATE_UNINITIALIZED),
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING));
108 if (state_ == STATE_LOGGING) 109 if (state_ == STATE_LOGGING)
109 return; 110 return;
110 111
111 DCHECK_NE(STATE_UNINITIALIZED, state_); 112 DCHECK_NE(STATE_UNINITIALIZED, state_);
112 DCHECK(!log_path_.empty()); 113 DCHECK(!log_path_.empty());
113 114
114 // Try to make sure we can create the file. 115 // Try to make sure we can create the file.
115 // TODO(rtenneti): Find a better for doing the following. Surface some error 116 // TODO(rtenneti): Find a better for doing the following. Surface some error
116 // to the user if we couldn't create the file. 117 // to the user if we couldn't create the file.
117 FILE* file = base::OpenFile(log_path_, "w"); 118 base::ScopedFILE file(base::OpenFile(log_path_, "w"));
118 if (file == NULL) 119 if (!file)
119 return; 120 return;
120 121
121 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); 122 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants());
122 net_log_logger_.reset(new net::NetLogLogger(file, *constants)); 123 net_log_logger_.reset(new net::NetLogLogger());
123 if (strip_private_data) { 124 if (strip_private_data) {
124 net_log_logger_->set_log_level(net::NetLog::LOG_STRIP_PRIVATE_DATA); 125 net_log_logger_->set_log_level(net::NetLog::LOG_STRIP_PRIVATE_DATA);
125 log_type_ = LOG_TYPE_STRIP_PRIVATE_DATA; 126 log_type_ = LOG_TYPE_STRIP_PRIVATE_DATA;
126 } else { 127 } else {
127 net_log_logger_->set_log_level(net::NetLog::LOG_ALL_BUT_BYTES); 128 net_log_logger_->set_log_level(net::NetLog::LOG_ALL_BUT_BYTES);
128 log_type_ = LOG_TYPE_NORMAL; 129 log_type_ = LOG_TYPE_NORMAL;
129 } 130 }
130 net_log_logger_->StartObserving(chrome_net_log_); 131 net_log_logger_->StartObserving(chrome_net_log_, file.Pass(), constants.get(),
132 nullptr);
131 state_ = STATE_LOGGING; 133 state_ = STATE_LOGGING;
132 } 134 }
133 135
134 void NetLogTempFile::StopNetLog() { 136 void NetLogTempFile::StopNetLog() {
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING));
136 if (state_ != STATE_LOGGING) 138 if (state_ != STATE_LOGGING)
137 return; 139 return;
138 140
139 net_log_logger_->StopObserving(); 141 net_log_logger_->StopObserving();
140 net_log_logger_.reset(); 142 net_log_logger_.reset();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 bool NetLogTempFile::GetNetExportLogDirectory(base::FilePath* path) { 175 bool NetLogTempFile::GetNetExportLogDirectory(base::FilePath* path) {
174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING));
175 return base::GetTempDir(path); 177 return base::GetTempDir(path);
176 } 178 }
177 179
178 bool NetLogTempFile::NetExportLogExists() { 180 bool NetLogTempFile::NetExportLogExists() {
179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING)); 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE_USER_BLOCKING));
180 DCHECK(!log_path_.empty()); 182 DCHECK(!log_path_.empty());
181 return base::PathExists(log_path_); 183 return base::PathExists(log_path_);
182 } 184 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698