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

Side by Side Diff: google_apis/gcm/tools/mcs_probe.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: Merge 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
« no previous file with comments | « content/shell/browser/shell_net_log.cc ('k') | net/base/net_log_logger.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 // A standalone tool for testing MCS connections and the MCS client on their 5 // A standalone tool for testing MCS connections and the MCS client on their
6 // own. 6 // own.
7 7
8 #include <cstddef> 8 #include <cstddef>
9 #include <cstdio> 9 #include <cstdio>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/at_exit.h" 13 #include "base/at_exit.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/files/scoped_file.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
19 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
20 #include "base/run_loop.h" 21 #include "base/run_loop.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
23 #include "base/threading/worker_pool.h" 24 #include "base/threading/worker_pool.h"
24 #include "base/time/default_clock.h" 25 #include "base/time/default_clock.h"
25 #include "base/values.h" 26 #include "base/values.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 server_host_ = command_line.GetSwitchValueASCII(kServerHostSwitch); 272 server_host_ = command_line.GetSwitchValueASCII(kServerHostSwitch);
272 } 273 }
273 server_port_ = kMCSServerPort; 274 server_port_ = kMCSServerPort;
274 if (command_line.HasSwitch(kServerPortSwitch)) { 275 if (command_line.HasSwitch(kServerPortSwitch)) {
275 base::StringToInt(command_line.GetSwitchValueASCII(kServerPortSwitch), 276 base::StringToInt(command_line.GetSwitchValueASCII(kServerPortSwitch),
276 &server_port_); 277 &server_port_);
277 } 278 }
278 } 279 }
279 280
280 MCSProbe::~MCSProbe() { 281 MCSProbe::~MCSProbe() {
282 if (logger_)
283 logger_->StopObserving(nullptr);
281 file_thread_.Stop(); 284 file_thread_.Stop();
282 } 285 }
283 286
284 void MCSProbe::Start() { 287 void MCSProbe::Start() {
285 file_thread_.Start(); 288 file_thread_.Start();
286 InitializeNetworkState(); 289 InitializeNetworkState();
287 BuildNetworkSession(); 290 BuildNetworkSession();
288 std::vector<GURL> endpoints(1, 291 std::vector<GURL> endpoints(1,
289 GURL("https://" + 292 GURL("https://" +
290 net::HostPortPair(server_host_, 293 net::HostPortPair(server_host_,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 return; 341 return;
339 } 342 }
340 343
341 StartMCSLogin(); 344 StartMCSLogin();
342 } 345 }
343 346
344 void MCSProbe::UpdateCallback(bool success) { 347 void MCSProbe::UpdateCallback(bool success) {
345 } 348 }
346 349
347 void MCSProbe::InitializeNetworkState() { 350 void MCSProbe::InitializeNetworkState() {
348 FILE* log_file = NULL; 351 base::ScopedFILE log_file;
349 if (command_line_.HasSwitch(kLogFileSwitch)) { 352 if (command_line_.HasSwitch(kLogFileSwitch)) {
350 base::FilePath log_path = command_line_.GetSwitchValuePath(kLogFileSwitch); 353 base::FilePath log_path = command_line_.GetSwitchValuePath(kLogFileSwitch);
351 #if defined(OS_WIN) 354 #if defined(OS_WIN)
352 log_file = _wfopen(log_path.value().c_str(), L"w"); 355 log_file.reset(_wfopen(log_path.value().c_str(), L"w"));
353 #elif defined(OS_POSIX) 356 #elif defined(OS_POSIX)
354 log_file = fopen(log_path.value().c_str(), "w"); 357 log_file.reset(fopen(log_path.value().c_str(), "w"));
355 #endif 358 #endif
356 } 359 }
357 if (log_file != NULL) { 360 if (log_file.get()) {
358 scoped_ptr<base::Value> net_constants(net::NetLogLogger::GetConstants()); 361 logger_.reset(new net::NetLogLogger());
359 logger_.reset(new net::NetLogLogger(log_file, *net_constants));
360 logger_->set_log_level(net::NetLog::LOG_ALL_BUT_BYTES); 362 logger_->set_log_level(net::NetLog::LOG_ALL_BUT_BYTES);
361 logger_->StartObserving(&net_log_); 363 logger_->StartObserving(&net_log_, log_file.Pass(), nullptr, nullptr);
362 } 364 }
363 365
364 host_resolver_ = net::HostResolver::CreateDefaultResolver(&net_log_); 366 host_resolver_ = net::HostResolver::CreateDefaultResolver(&net_log_);
365 367
366 if (command_line_.HasSwitch(kIgnoreCertSwitch)) { 368 if (command_line_.HasSwitch(kIgnoreCertSwitch)) {
367 cert_verifier_.reset(new MyTestCertVerifier()); 369 cert_verifier_.reset(new MyTestCertVerifier());
368 } else { 370 } else {
369 cert_verifier_.reset(net::CertVerifier::CreateDefault()); 371 cert_verifier_.reset(net::CertVerifier::CreateDefault());
370 } 372 }
371 system_channel_id_service_.reset( 373 system_channel_id_service_.reset(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 495
494 return 0; 496 return 0;
495 } 497 }
496 498
497 } // namespace 499 } // namespace
498 } // namespace gcm 500 } // namespace gcm
499 501
500 int main(int argc, char* argv[]) { 502 int main(int argc, char* argv[]) {
501 return gcm::MCSProbeMain(argc, argv); 503 return gcm::MCSProbeMain(argc, argv);
502 } 504 }
OLDNEW
« no previous file with comments | « content/shell/browser/shell_net_log.cc ('k') | net/base/net_log_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698