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

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/net_internals/net_internals_ui_browsertest.h" 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/files/scoped_file.h"
12 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/io_thread.h" 18 #include "chrome/browser/io_thread.h"
18 #include "chrome/browser/net/chrome_net_log.h" 19 #include "chrome/browser/net/chrome_net_log.h"
19 #include "chrome/browser/prerender/prerender_manager.h" 20 #include "chrome/browser/prerender/prerender_manager.h"
20 #include "chrome/browser/prerender/prerender_manager_factory.h" 21 #include "chrome/browser/prerender/prerender_manager_factory.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 incognito_browser_ = NULL; 271 incognito_browser_ = NULL;
271 } 272 }
272 273
273 void NetInternalsTest::MessageHandler::GetNetLogLoggerLog( 274 void NetInternalsTest::MessageHandler::GetNetLogLoggerLog(
274 const base::ListValue* list_value) { 275 const base::ListValue* list_value) {
275 base::ScopedTempDir temp_directory; 276 base::ScopedTempDir temp_directory;
276 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); 277 ASSERT_TRUE(temp_directory.CreateUniqueTempDir());
277 base::FilePath temp_file; 278 base::FilePath temp_file;
278 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(), 279 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_directory.path(),
279 &temp_file)); 280 &temp_file));
280 FILE* temp_file_handle = base::OpenFile(temp_file, "w"); 281 base::ScopedFILE temp_file_handle(base::OpenFile(temp_file, "w"));
281 ASSERT_TRUE(temp_file_handle); 282 ASSERT_TRUE(temp_file_handle);
282 283
283 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants()); 284 scoped_ptr<base::Value> constants(NetInternalsUI::GetConstants());
284 scoped_ptr<net::NetLogLogger> net_log_logger(new net::NetLogLogger( 285 scoped_ptr<net::NetLogLogger> net_log_logger(new net::NetLogLogger());
285 temp_file_handle, *constants)); 286 net_log_logger->StartObserving(
286 net_log_logger->StartObserving(g_browser_process->net_log()); 287 g_browser_process->net_log(), temp_file_handle.Pass(), constants.get(),
288 nullptr);
287 g_browser_process->net_log()->AddGlobalEntry( 289 g_browser_process->net_log()->AddGlobalEntry(
288 net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED); 290 net::NetLog::TYPE_NETWORK_IP_ADDRESSES_CHANGED);
289 net::BoundNetLog bound_net_log = net::BoundNetLog::Make( 291 net::BoundNetLog bound_net_log = net::BoundNetLog::Make(
290 g_browser_process->net_log(), 292 g_browser_process->net_log(),
291 net::NetLog::SOURCE_URL_REQUEST); 293 net::NetLog::SOURCE_URL_REQUEST);
292 bound_net_log.BeginEvent(net::NetLog::TYPE_REQUEST_ALIVE); 294 bound_net_log.BeginEvent(net::NetLog::TYPE_REQUEST_ALIVE);
293 net_log_logger->StopObserving(); 295 net_log_logger->StopObserving(nullptr);
294 net_log_logger.reset(); 296 net_log_logger.reset();
295 297
296 std::string log_contents; 298 std::string log_contents;
297 ASSERT_TRUE(base::ReadFileToString(temp_file, &log_contents)); 299 ASSERT_TRUE(base::ReadFileToString(temp_file, &log_contents));
298 ASSERT_GT(log_contents.length(), 0u); 300 ASSERT_GT(log_contents.length(), 0u);
299 301
300 scoped_ptr<base::Value> log_contents_value( 302 scoped_ptr<base::Value> log_contents_value(
301 new base::StringValue(log_contents)); 303 new base::StringValue(log_contents));
302 RunJavascriptCallback(log_contents_value.get()); 304 RunJavascriptCallback(log_contents_value.get());
303 } 305 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (test_server_started_) 364 if (test_server_started_)
363 return true; 365 return true;
364 test_server_started_ = test_server()->Start(); 366 test_server_started_ = test_server()->Start();
365 367
366 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1 368 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1
367 // are forbidden. 369 // are forbidden.
368 host_resolver()->AddRule("testdomain.com", "127.0.0.1"); 370 host_resolver()->AddRule("testdomain.com", "127.0.0.1");
369 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1"); 371 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1");
370 return test_server_started_; 372 return test_server_started_;
371 } 373 }
OLDNEW
« no previous file with comments | « chrome/browser/net/net_log_temp_file.cc ('k') | components/cronet/android/cronet_url_request_context_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698