OLD | NEW |
---|---|
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.h" | 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" |
6 | 6 |
7 #include <algorithm> | |
8 #include <list> | 7 #include <list> |
9 #include <string> | 8 #include <string> |
10 #include <utility> | 9 #include <utility> |
11 #include <vector> | 10 #include <vector> |
12 | 11 |
13 #include "base/base64.h" | 12 #include "base/base64.h" |
14 #include "base/bind.h" | 13 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
16 #include "base/command_line.h" | 15 #include "base/command_line.h" |
17 #include "base/file_path.h" | 16 #include "base/file_path.h" |
18 #include "base/file_util.h" | 17 #include "base/file_util.h" |
19 #include "base/memory/singleton.h" | |
20 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
21 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
22 #include "base/path_service.h" | |
23 #include "base/platform_file.h" | 20 #include "base/platform_file.h" |
24 #include "base/sequenced_task_runner_helpers.h" | 21 #include "base/sequenced_task_runner_helpers.h" |
25 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
26 #include "base/string_piece.h" | 23 #include "base/string_piece.h" |
27 #include "base/string_split.h" | 24 #include "base/string_split.h" |
28 #include "base/string_util.h" | 25 #include "base/string_util.h" |
29 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
30 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
31 #include "base/values.h" | 28 #include "base/values.h" |
32 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
49 #include "chrome/common/logging_chrome.h" | 46 #include "chrome/common/logging_chrome.h" |
50 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
51 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
52 #include "content/public/browser/browser_thread.h" | 49 #include "content/public/browser/browser_thread.h" |
53 #include "content/public/browser/notification_details.h" | 50 #include "content/public/browser/notification_details.h" |
54 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
55 #include "content/public/browser/web_ui.h" | 52 #include "content/public/browser/web_ui.h" |
56 #include "content/public/browser/web_ui_message_handler.h" | 53 #include "content/public/browser/web_ui_message_handler.h" |
57 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
58 #include "grit/net_internals_resources.h" | 55 #include "grit/net_internals_resources.h" |
59 #include "net/base/escape.h" | |
60 #include "net/base/host_cache.h" | 56 #include "net/base/host_cache.h" |
61 #include "net/base/host_resolver.h" | 57 #include "net/base/host_resolver.h" |
62 #include "net/base/net_errors.h" | 58 #include "net/base/net_errors.h" |
63 #include "net/base/net_util.h" | 59 #include "net/base/net_util.h" |
64 #include "net/base/transport_security_state.h" | 60 #include "net/base/transport_security_state.h" |
65 #include "net/base/x509_cert_types.h" | |
66 #include "net/disk_cache/disk_cache.h" | 61 #include "net/disk_cache/disk_cache.h" |
67 #include "net/http/http_cache.h" | 62 #include "net/http/http_cache.h" |
68 #include "net/http/http_network_layer.h" | 63 #include "net/http/http_network_layer.h" |
69 #include "net/http/http_network_session.h" | 64 #include "net/http/http_network_session.h" |
70 #include "net/http/http_server_properties.h" | 65 #include "net/http/http_server_properties.h" |
71 #include "net/http/http_stream_factory.h" | 66 #include "net/http/http_stream_factory.h" |
72 #include "net/proxy/proxy_service.h" | 67 #include "net/proxy/proxy_service.h" |
73 #include "net/url_request/url_request_context.h" | 68 #include "net/url_request/url_request_context.h" |
74 #include "net/url_request/url_request_context_getter.h" | 69 #include "net/url_request/url_request_context_getter.h" |
75 #include "ui/base/l10n/l10n_util.h" | |
76 #include "ui/base/resource/resource_bundle.h" | 70 #include "ui/base/resource/resource_bundle.h" |
77 | 71 |
78 #ifdef OS_CHROMEOS | 72 #if defined(OS_CHROMEOS) |
79 #include "chrome/browser/chromeos/cros/cros_library.h" | 73 #include "chrome/browser/chromeos/cros/cros_library.h" |
80 #include "chrome/browser/chromeos/cros/network_library.h" | 74 #include "chrome/browser/chromeos/cros/network_library.h" |
81 #include "chrome/browser/chromeos/system/syslogs_provider.h" | 75 #include "chrome/browser/chromeos/system/syslogs_provider.h" |
82 #include "chromeos/dbus/dbus_thread_manager.h" | 76 #include "chromeos/dbus/dbus_thread_manager.h" |
83 #include "chromeos/dbus/debug_daemon_client.h" | 77 #include "chromeos/dbus/debug_daemon_client.h" |
84 #endif | 78 #endif |
85 #ifdef OS_WIN | 79 #if defined(OS_WIN) |
86 #include "chrome/browser/net/service_providers_win.h" | 80 #include "chrome/browser/net/service_providers_win.h" |
87 #endif | 81 #endif |
88 | 82 |
89 using base::PassPlatformFile; | 83 using base::PassPlatformFile; |
90 using base::PlatformFile; | 84 using base::PlatformFile; |
91 using base::PlatformFileError; | 85 using base::PlatformFileError; |
92 using content::BrowserThread; | 86 using content::BrowserThread; |
93 using content::WebContents; | 87 using content::WebContents; |
94 using content::WebUIMessageHandler; | 88 using content::WebUIMessageHandler; |
95 | 89 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 new ChromeWebUIDataSource(chrome::kChromeUINetInternalsHost); | 147 new ChromeWebUIDataSource(chrome::kChromeUINetInternalsHost); |
154 | 148 |
155 source->set_default_resource(IDR_NET_INTERNALS_INDEX_HTML); | 149 source->set_default_resource(IDR_NET_INTERNALS_INDEX_HTML); |
156 source->add_resource_path("help.html", IDR_NET_INTERNALS_HELP_HTML); | 150 source->add_resource_path("help.html", IDR_NET_INTERNALS_HELP_HTML); |
157 source->add_resource_path("help.js", IDR_NET_INTERNALS_HELP_JS); | 151 source->add_resource_path("help.js", IDR_NET_INTERNALS_HELP_JS); |
158 source->add_resource_path("index.js", IDR_NET_INTERNALS_INDEX_JS); | 152 source->add_resource_path("index.js", IDR_NET_INTERNALS_INDEX_JS); |
159 source->set_json_path("strings.js"); | 153 source->set_json_path("strings.js"); |
160 return source; | 154 return source; |
161 } | 155 } |
162 | 156 |
163 #ifdef OS_CHROMEOS | 157 #if defined(OS_CHROMEOS) |
164 // Small helper class used to create temporary log file and pass its | 158 // Small helper class used to create temporary log file and pass its |
165 // handle and error status to callback. | 159 // handle and error status to callback. |
166 // Use case: | 160 // Use case: |
167 // DebugLogFileHelper* helper = new DebugLogFileHelper(); | 161 // DebugLogFileHelper* helper = new DebugLogFileHelper(); |
168 // base::WorkerPool::PostTaskAndReply(FROM_HERE, | 162 // base::WorkerPool::PostTaskAndReply(FROM_HERE, |
169 // base::Bind(&DebugLogFileHelper::DoWork, base::Unretained(helper), ...), | 163 // base::Bind(&DebugLogFileHelper::DoWork, base::Unretained(helper), ...), |
170 // base::Bind(&DebugLogFileHelper::Reply, base::Owned(helper), ...), | 164 // base::Bind(&DebugLogFileHelper::Reply, base::Owned(helper), ...), |
171 // false); | 165 // false); |
172 class DebugLogFileHelper { | 166 class DebugLogFileHelper { |
173 public: | 167 public: |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 DCHECK(!callback.is_null()); | 285 DCHECK(!callback.is_null()); |
292 const FilePath fileshelf = download_util::GetDefaultDownloadDirectory(); | 286 const FilePath fileshelf = download_util::GetDefaultDownloadDirectory(); |
293 DebugLogFileHelper* helper = new DebugLogFileHelper(); | 287 DebugLogFileHelper* helper = new DebugLogFileHelper(); |
294 bool posted = base::WorkerPool::PostTaskAndReply(FROM_HERE, | 288 bool posted = base::WorkerPool::PostTaskAndReply(FROM_HERE, |
295 base::Bind(&DebugLogFileHelper::DoWork, | 289 base::Bind(&DebugLogFileHelper::DoWork, |
296 base::Unretained(helper), fileshelf), | 290 base::Unretained(helper), fileshelf), |
297 base::Bind(&DebugLogFileHelper::Reply, base::Owned(helper), | 291 base::Bind(&DebugLogFileHelper::Reply, base::Owned(helper), |
298 base::Bind(&WriteDebugLogToFile, callback)), false); | 292 base::Bind(&WriteDebugLogToFile, callback)), false); |
299 DCHECK(posted); | 293 DCHECK(posted); |
300 } | 294 } |
301 #endif // OS_CHROMEOS | 295 #endif // defined(OS_CHROMEOS) |
302 | 296 |
303 // This class receives javascript messages from the renderer. | 297 // This class receives javascript messages from the renderer. |
304 // Note that the WebUI infrastructure runs on the UI thread, therefore all of | 298 // Note that the WebUI infrastructure runs on the UI thread, therefore all of |
305 // this class's methods are expected to run on the UI thread. | 299 // this class's methods are expected to run on the UI thread. |
306 // | 300 // |
307 // Since the network code we want to run lives on the IO thread, we proxy | 301 // Since the network code we want to run lives on the IO thread, we proxy |
308 // almost everything over to NetInternalsMessageHandler::IOThreadImpl, which | 302 // almost everything over to NetInternalsMessageHandler::IOThreadImpl, which |
309 // runs on the IO thread. | 303 // runs on the IO thread. |
310 // | 304 // |
311 // TODO(eroman): Can we start on the IO thread to begin with? | 305 // TODO(eroman): Can we start on the IO thread to begin with? |
312 class NetInternalsMessageHandler | 306 class NetInternalsMessageHandler |
313 : public WebUIMessageHandler, | 307 : public WebUIMessageHandler, |
314 public base::SupportsWeakPtr<NetInternalsMessageHandler> { | 308 public base::SupportsWeakPtr<NetInternalsMessageHandler> { |
315 public: | 309 public: |
316 NetInternalsMessageHandler(); | 310 NetInternalsMessageHandler(); |
317 virtual ~NetInternalsMessageHandler(); | 311 virtual ~NetInternalsMessageHandler(); |
318 | 312 |
319 // WebUIMessageHandler implementation. | 313 // WebUIMessageHandler implementation. |
320 virtual void RegisterMessages() OVERRIDE; | 314 virtual void RegisterMessages() OVERRIDE; |
321 | 315 |
322 // Calls g_browser.receive in the renderer, passing in |command| and |arg|. | 316 // Calls g_browser.receive in the renderer, passing in |command| and |arg|. |
323 // Takes ownership of |arg|. If the renderer is displaying a log file, the | 317 // Takes ownership of |arg|. If the renderer is displaying a log file, the |
324 // message will be ignored. | 318 // message will be ignored. |
325 void SendJavascriptCommand(const std::string& command, Value* arg); | 319 void SendJavascriptCommand(const std::string& command, Value* arg); |
326 | 320 |
327 // Javascript message handlers. | 321 // Javascript message handlers. |
328 void OnRendererReady(const ListValue* list); | 322 void OnRendererReady(const ListValue* list); |
329 void OnClearBrowserCache(const ListValue* list); | 323 void OnClearBrowserCache(const ListValue* list); |
330 void OnGetPrerenderInfo(const ListValue* list); | 324 void OnGetPrerenderInfo(const ListValue* list); |
331 #ifdef OS_CHROMEOS | 325 #if defined(OS_CHROMEOS) |
332 void OnRefreshSystemLogs(const ListValue* list); | 326 void OnRefreshSystemLogs(const ListValue* list); |
333 void OnGetSystemLog(const ListValue* list); | 327 void OnGetSystemLog(const ListValue* list); |
334 void OnImportONCFile(const ListValue* list); | 328 void OnImportONCFile(const ListValue* list); |
335 void OnStoreDebugLogs(const ListValue* list); | 329 void OnStoreDebugLogs(const ListValue* list); |
336 void OnStoreDebugLogsCompleted(const FilePath& log_path, bool succeeded); | 330 void OnStoreDebugLogsCompleted(const FilePath& log_path, bool succeeded); |
337 void OnSetNetworkDebugMode(const ListValue* list); | 331 void OnSetNetworkDebugMode(const ListValue* list); |
338 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, | 332 void OnSetNetworkDebugModeCompleted(const std::string& subsystem, |
339 bool succeeded); | 333 bool succeeded); |
340 #endif | 334 #endif |
341 | 335 |
342 private: | 336 private: |
343 class IOThreadImpl; | 337 class IOThreadImpl; |
344 | 338 |
345 #ifdef OS_CHROMEOS | 339 #if defined(OS_CHROMEOS) |
346 // Class that is used for getting network related ChromeOS logs. | 340 // Class that is used for getting network related ChromeOS logs. |
347 // Logs are fetched from ChromeOS libcros on user request, and only when we | 341 // Logs are fetched from ChromeOS libcros on user request, and only when we |
348 // don't yet have a copy of logs. If a copy is present, we send back data from | 342 // don't yet have a copy of logs. If a copy is present, we send back data from |
349 // it, else we save request and answer to it when we get logs from libcros. | 343 // it, else we save request and answer to it when we get logs from libcros. |
350 // If needed, we also send request for system logs to libcros. | 344 // If needed, we also send request for system logs to libcros. |
351 // Logs refresh has to be done explicitly, by deleting old logs and then | 345 // Logs refresh has to be done explicitly, by deleting old logs and then |
352 // loading them again. | 346 // loading them again. |
353 class SystemLogsGetter { | 347 class SystemLogsGetter { |
354 public: | 348 public: |
355 SystemLogsGetter(NetInternalsMessageHandler* handler, | 349 SystemLogsGetter(NetInternalsMessageHandler* handler, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 chromeos::system::SyslogsProvider* syslogs_provider_; | 382 chromeos::system::SyslogsProvider* syslogs_provider_; |
389 // List of postponed requests. | 383 // List of postponed requests. |
390 std::list<SystemLogRequest> requests_; | 384 std::list<SystemLogRequest> requests_; |
391 scoped_ptr<chromeos::system::LogDictionaryType> logs_; | 385 scoped_ptr<chromeos::system::LogDictionaryType> logs_; |
392 bool logs_received_; | 386 bool logs_received_; |
393 bool logs_requested_; | 387 bool logs_requested_; |
394 CancelableRequestConsumer consumer_; | 388 CancelableRequestConsumer consumer_; |
395 // Libcros request handle. | 389 // Libcros request handle. |
396 CancelableRequestProvider::Handle syslogs_request_id_; | 390 CancelableRequestProvider::Handle syslogs_request_id_; |
397 }; | 391 }; |
398 #endif | 392 #endif // defined(OS_CHROMEOS) |
399 | 393 |
400 // This is the "real" message handler, which lives on the IO thread. | 394 // This is the "real" message handler, which lives on the IO thread. |
401 scoped_refptr<IOThreadImpl> proxy_; | 395 scoped_refptr<IOThreadImpl> proxy_; |
402 | 396 |
403 base::WeakPtr<prerender::PrerenderManager> prerender_manager_; | 397 base::WeakPtr<prerender::PrerenderManager> prerender_manager_; |
404 | 398 |
405 #ifdef OS_CHROMEOS | 399 #if defined(OS_CHROMEOS) |
406 // Class that handles getting and filtering system logs. | 400 // Class that handles getting and filtering system logs. |
407 scoped_ptr<SystemLogsGetter> syslogs_getter_; | 401 scoped_ptr<SystemLogsGetter> syslogs_getter_; |
408 #endif | 402 #endif |
409 | 403 |
410 DISALLOW_COPY_AND_ASSIGN(NetInternalsMessageHandler); | 404 DISALLOW_COPY_AND_ASSIGN(NetInternalsMessageHandler); |
411 }; | 405 }; |
412 | 406 |
413 // This class is the "real" message handler. It is allocated and destroyed on | 407 // This class is the "real" message handler. It is allocated and destroyed on |
414 // the UI thread. With the exception of OnAddEntry, OnWebUIDeleted, and | 408 // the UI thread. With the exception of OnAddEntry, OnWebUIDeleted, and |
415 // SendJavascriptCommand, its methods are all expected to be called from the IO | 409 // SendJavascriptCommand, its methods are all expected to be called from the IO |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 void OnHSTSQuery(const ListValue* list); | 460 void OnHSTSQuery(const ListValue* list); |
467 void OnHSTSAdd(const ListValue* list); | 461 void OnHSTSAdd(const ListValue* list); |
468 void OnHSTSDelete(const ListValue* list); | 462 void OnHSTSDelete(const ListValue* list); |
469 void OnGetHttpCacheInfo(const ListValue* list); | 463 void OnGetHttpCacheInfo(const ListValue* list); |
470 void OnGetSocketPoolInfo(const ListValue* list); | 464 void OnGetSocketPoolInfo(const ListValue* list); |
471 void OnCloseIdleSockets(const ListValue* list); | 465 void OnCloseIdleSockets(const ListValue* list); |
472 void OnFlushSocketPools(const ListValue* list); | 466 void OnFlushSocketPools(const ListValue* list); |
473 void OnGetSpdySessionInfo(const ListValue* list); | 467 void OnGetSpdySessionInfo(const ListValue* list); |
474 void OnGetSpdyStatus(const ListValue* list); | 468 void OnGetSpdyStatus(const ListValue* list); |
475 void OnGetSpdyAlternateProtocolMappings(const ListValue* list); | 469 void OnGetSpdyAlternateProtocolMappings(const ListValue* list); |
476 #ifdef OS_WIN | 470 #if defined(OS_WIN) |
477 void OnGetServiceProviders(const ListValue* list); | 471 void OnGetServiceProviders(const ListValue* list); |
478 #endif | 472 #endif |
479 void OnGetHttpPipeliningStatus(const ListValue* list); | 473 void OnGetHttpPipeliningStatus(const ListValue* list); |
480 void OnSetLogLevel(const ListValue* list); | 474 void OnSetLogLevel(const ListValue* list); |
481 | 475 |
482 // ChromeNetLog::ThreadSafeObserver implementation: | 476 // ChromeNetLog::ThreadSafeObserver implementation: |
483 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; | 477 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; |
484 | 478 |
485 // ConnectionTester::Delegate implementation: | 479 // ConnectionTester::Delegate implementation: |
486 virtual void OnStartConnectionTestSuite() OVERRIDE; | 480 virtual void OnStartConnectionTestSuite() OVERRIDE; |
487 virtual void OnStartConnectionTestExperiment( | 481 virtual void OnStartConnectionTestExperiment( |
488 const ConnectionTester::Experiment& experiment) OVERRIDE; | 482 const ConnectionTester::Experiment& experiment) OVERRIDE; |
489 virtual void OnCompletedConnectionTestExperiment( | 483 virtual void OnCompletedConnectionTestExperiment( |
490 const ConnectionTester::Experiment& experiment, | 484 const ConnectionTester::Experiment& experiment, |
491 int result) OVERRIDE; | 485 int result) OVERRIDE; |
492 virtual void OnCompletedConnectionTestSuite() OVERRIDE; | 486 virtual void OnCompletedConnectionTestSuite() OVERRIDE; |
493 | 487 |
494 // Helper that calls g_browser.receive in the renderer, passing in |command| | 488 // Helper that calls g_browser.receive in the renderer, passing in |command| |
495 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log | 489 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log |
496 // file, the message will be ignored. Note that this can be called from any | 490 // file, the message will be ignored. Note that this can be called from any |
497 // thread. | 491 // thread. |
498 void SendJavascriptCommand(const std::string& command, Value* arg); | 492 void SendJavascriptCommand(const std::string& command, Value* arg); |
499 | 493 |
500 // Helper that runs |method| with |arg|, and deletes |arg| on completion. | 494 // Helper that runs |method| with |arg|, and deletes |arg| on completion. |
501 void DispatchToMessageHandler(ListValue* arg, MessageHandler method); | 495 void DispatchToMessageHandler(ListValue* arg, MessageHandler method); |
eroman
2012/08/01 23:10:05
Delete this, it is dead code.
| |
502 | 496 |
503 private: | 497 private: |
504 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 498 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
505 friend class base::DeleteHelper<IOThreadImpl>; | 499 friend class base::DeleteHelper<IOThreadImpl>; |
506 | 500 |
507 ~IOThreadImpl(); | 501 ~IOThreadImpl(); |
508 | 502 |
509 // Adds |entry| to the queue of pending log entries to be sent to the page via | 503 // Adds |entry| to the queue of pending log entries to be sent to the page via |
510 // Javascript. Must be called on the IO Thread. Also creates a delayed task | 504 // Javascript. Must be called on the IO Thread. Also creates a delayed task |
511 // that will call PostPendingEntries, if there isn't one already. | 505 // that will call PostPendingEntries, if there isn't one already. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 } | 554 } |
561 } | 555 } |
562 | 556 |
563 void NetInternalsMessageHandler::RegisterMessages() { | 557 void NetInternalsMessageHandler::RegisterMessages() { |
564 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 558 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
565 | 559 |
566 Profile* profile = Profile::FromWebUI(web_ui()); | 560 Profile* profile = Profile::FromWebUI(web_ui()); |
567 | 561 |
568 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), | 562 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), |
569 profile->GetRequestContext()); | 563 profile->GetRequestContext()); |
570 #ifdef OS_CHROMEOS | 564 #if defined(OS_CHROMEOS) |
571 syslogs_getter_.reset(new SystemLogsGetter(this, | 565 syslogs_getter_.reset(new SystemLogsGetter(this, |
572 chromeos::system::SyslogsProvider::GetInstance())); | 566 chromeos::system::SyslogsProvider::GetInstance())); |
573 #endif | 567 #endif |
574 | 568 |
575 prerender::PrerenderManager* prerender_manager = | 569 prerender::PrerenderManager* prerender_manager = |
576 prerender::PrerenderManagerFactory::GetForProfile(profile); | 570 prerender::PrerenderManagerFactory::GetForProfile(profile); |
577 if (prerender_manager) { | 571 if (prerender_manager) { |
578 prerender_manager_ = prerender_manager->AsWeakPtr(); | 572 prerender_manager_ = prerender_manager->AsWeakPtr(); |
579 } else { | 573 } else { |
580 prerender_manager_ = base::WeakPtr<prerender::PrerenderManager>(); | 574 prerender_manager_ = base::WeakPtr<prerender::PrerenderManager>(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 base::Bind(&IOThreadImpl::CallbackHelper, | 647 base::Bind(&IOThreadImpl::CallbackHelper, |
654 &IOThreadImpl::OnGetSpdySessionInfo, proxy_)); | 648 &IOThreadImpl::OnGetSpdySessionInfo, proxy_)); |
655 web_ui()->RegisterMessageCallback( | 649 web_ui()->RegisterMessageCallback( |
656 "getSpdyStatus", | 650 "getSpdyStatus", |
657 base::Bind(&IOThreadImpl::CallbackHelper, | 651 base::Bind(&IOThreadImpl::CallbackHelper, |
658 &IOThreadImpl::OnGetSpdyStatus, proxy_)); | 652 &IOThreadImpl::OnGetSpdyStatus, proxy_)); |
659 web_ui()->RegisterMessageCallback( | 653 web_ui()->RegisterMessageCallback( |
660 "getSpdyAlternateProtocolMappings", | 654 "getSpdyAlternateProtocolMappings", |
661 base::Bind(&IOThreadImpl::CallbackHelper, | 655 base::Bind(&IOThreadImpl::CallbackHelper, |
662 &IOThreadImpl::OnGetSpdyAlternateProtocolMappings, proxy_)); | 656 &IOThreadImpl::OnGetSpdyAlternateProtocolMappings, proxy_)); |
663 #ifdef OS_WIN | 657 #if defined(OS_WIN) |
664 web_ui()->RegisterMessageCallback( | 658 web_ui()->RegisterMessageCallback( |
665 "getServiceProviders", | 659 "getServiceProviders", |
666 base::Bind(&IOThreadImpl::CallbackHelper, | 660 base::Bind(&IOThreadImpl::CallbackHelper, |
667 &IOThreadImpl::OnGetServiceProviders, proxy_)); | 661 &IOThreadImpl::OnGetServiceProviders, proxy_)); |
668 #endif | 662 #endif |
669 | 663 |
670 web_ui()->RegisterMessageCallback( | 664 web_ui()->RegisterMessageCallback( |
671 "getHttpPipeliningStatus", | 665 "getHttpPipeliningStatus", |
672 base::Bind(&IOThreadImpl::CallbackHelper, | 666 base::Bind(&IOThreadImpl::CallbackHelper, |
673 &IOThreadImpl::OnGetHttpPipeliningStatus, proxy_)); | 667 &IOThreadImpl::OnGetHttpPipeliningStatus, proxy_)); |
674 web_ui()->RegisterMessageCallback( | 668 web_ui()->RegisterMessageCallback( |
675 "setLogLevel", | 669 "setLogLevel", |
676 base::Bind(&IOThreadImpl::CallbackHelper, | 670 base::Bind(&IOThreadImpl::CallbackHelper, |
677 &IOThreadImpl::OnSetLogLevel, proxy_)); | 671 &IOThreadImpl::OnSetLogLevel, proxy_)); |
678 web_ui()->RegisterMessageCallback( | 672 web_ui()->RegisterMessageCallback( |
679 "clearBrowserCache", | 673 "clearBrowserCache", |
680 base::Bind(&NetInternalsMessageHandler::OnClearBrowserCache, | 674 base::Bind(&NetInternalsMessageHandler::OnClearBrowserCache, |
681 base::Unretained(this))); | 675 base::Unretained(this))); |
682 web_ui()->RegisterMessageCallback( | 676 web_ui()->RegisterMessageCallback( |
683 "getPrerenderInfo", | 677 "getPrerenderInfo", |
684 base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, | 678 base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, |
685 base::Unretained(this))); | 679 base::Unretained(this))); |
686 #ifdef OS_CHROMEOS | 680 #if defined(OS_CHROMEOS) |
687 web_ui()->RegisterMessageCallback( | 681 web_ui()->RegisterMessageCallback( |
688 "refreshSystemLogs", | 682 "refreshSystemLogs", |
689 base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs, | 683 base::Bind(&NetInternalsMessageHandler::OnRefreshSystemLogs, |
690 base::Unretained(this))); | 684 base::Unretained(this))); |
691 web_ui()->RegisterMessageCallback( | 685 web_ui()->RegisterMessageCallback( |
692 "getSystemLog", | 686 "getSystemLog", |
693 base::Bind(&NetInternalsMessageHandler::OnGetSystemLog, | 687 base::Bind(&NetInternalsMessageHandler::OnGetSystemLog, |
694 base::Unretained(this))); | 688 base::Unretained(this))); |
695 web_ui()->RegisterMessageCallback( | 689 web_ui()->RegisterMessageCallback( |
696 "importONCFile", | 690 "importONCFile", |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
746 value = new DictionaryValue(); | 740 value = new DictionaryValue(); |
747 value->SetBoolean("enabled", false); | 741 value->SetBoolean("enabled", false); |
748 value->SetBoolean("omnibox_enabled", false); | 742 value->SetBoolean("omnibox_enabled", false); |
749 } else { | 743 } else { |
750 value = prerender_manager->GetAsValue(); | 744 value = prerender_manager->GetAsValue(); |
751 } | 745 } |
752 SendJavascriptCommand("receivedPrerenderInfo", value); | 746 SendJavascriptCommand("receivedPrerenderInfo", value); |
753 } | 747 } |
754 | 748 |
755 | 749 |
756 #ifdef OS_CHROMEOS | 750 #if defined(OS_CHROMEOS) |
757 //////////////////////////////////////////////////////////////////////////////// | 751 //////////////////////////////////////////////////////////////////////////////// |
758 // | 752 // |
759 // NetInternalsMessageHandler::SystemLogsGetter | 753 // NetInternalsMessageHandler::SystemLogsGetter |
760 // | 754 // |
761 //////////////////////////////////////////////////////////////////////////////// | 755 //////////////////////////////////////////////////////////////////////////////// |
762 | 756 |
763 NetInternalsMessageHandler::SystemLogsGetter::SystemLogsGetter( | 757 NetInternalsMessageHandler::SystemLogsGetter::SystemLogsGetter( |
764 NetInternalsMessageHandler* handler, | 758 NetInternalsMessageHandler* handler, |
765 chromeos::system::SyslogsProvider* syslogs_provider) | 759 chromeos::system::SyslogsProvider* syslogs_provider) |
766 : handler_(handler), | 760 : handler_(handler), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 } else { | 834 } else { |
841 result->SetString("log", "<no relevant lines found>"); | 835 result->SetString("log", "<no relevant lines found>"); |
842 } | 836 } |
843 } else { | 837 } else { |
844 result->SetString("log", "<invalid log name>"); | 838 result->SetString("log", "<invalid log name>"); |
845 } | 839 } |
846 result->SetString("cellId", request.cell_id); | 840 result->SetString("cellId", request.cell_id); |
847 | 841 |
848 handler_->SendJavascriptCommand("getSystemLogCallback", result); | 842 handler_->SendJavascriptCommand("getSystemLogCallback", result); |
849 } | 843 } |
850 #endif | 844 #endif // defined(OS_CHROMEOS) |
845 | |
851 //////////////////////////////////////////////////////////////////////////////// | 846 //////////////////////////////////////////////////////////////////////////////// |
852 // | 847 // |
853 // NetInternalsMessageHandler::IOThreadImpl | 848 // NetInternalsMessageHandler::IOThreadImpl |
854 // | 849 // |
855 //////////////////////////////////////////////////////////////////////////////// | 850 //////////////////////////////////////////////////////////////////////////////// |
856 | 851 |
857 NetInternalsMessageHandler::IOThreadImpl::IOThreadImpl( | 852 NetInternalsMessageHandler::IOThreadImpl::IOThreadImpl( |
858 const base::WeakPtr<NetInternalsMessageHandler>& handler, | 853 const base::WeakPtr<NetInternalsMessageHandler>& handler, |
859 IOThread* io_thread, | 854 IOThread* io_thread, |
860 net::URLRequestContextGetter* context_getter) | 855 net::URLRequestContextGetter* context_getter) |
861 : handler_(handler), | 856 : handler_(handler), |
862 io_thread_(io_thread), | 857 io_thread_(io_thread), |
863 context_getter_(context_getter), | 858 context_getter_(context_getter), |
864 was_webui_deleted_(false) { | 859 was_webui_deleted_(false) { |
865 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 860 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
866 } | 861 } |
867 | 862 |
868 NetInternalsMessageHandler::IOThreadImpl::~IOThreadImpl() { | 863 NetInternalsMessageHandler::IOThreadImpl::~IOThreadImpl() { |
869 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 864 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
870 } | 865 } |
871 | 866 |
872 void NetInternalsMessageHandler::IOThreadImpl::CallbackHelper( | 867 void NetInternalsMessageHandler::IOThreadImpl::CallbackHelper( |
873 MessageHandler method, | 868 MessageHandler method, |
874 scoped_refptr<IOThreadImpl> io_thread, | 869 scoped_refptr<IOThreadImpl> io_thread, |
875 const ListValue* list) { | 870 const ListValue* list) { |
876 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 871 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
877 | 872 |
878 // We need to make a copy of the value in order to pass it over to the IO | 873 // We need to make a copy of the value in order to pass it over to the IO |
879 // thread. We will delete this in IOThreadImpl::DispatchMessageHandler(). | 874 // thread. We will delete |list| in IOThreadImpl::DispatchToMessageHandler(). |
eroman
2012/08/01 23:10:05
Remove the reference to DispatchToMessageHandler.
| |
880 ListValue* list_copy = | 875 // |list_copy| will deleted when the task is destroyed. The called |method| |
eroman
2012/08/01 23:10:05
"will deleted" --> "will be deleted"
| |
881 static_cast<ListValue*>(list ? list->DeepCopy() : NULL); | 876 // cannot take ownership of |list_copy|. |
877 ListValue* list_copy = (list && list->GetSize()) ? list->DeepCopy() : NULL; | |
882 | 878 |
883 if (!BrowserThread::PostTask( | 879 BrowserThread::PostTask( |
884 BrowserThread::IO, FROM_HERE, | 880 BrowserThread::IO, FROM_HERE, |
885 base::Bind(method, io_thread, list_copy))) { | 881 base::Bind(method, io_thread, base::Owned(list_copy))); |
886 // Failed posting the task, avoid leaking |list_copy|. | |
887 delete list_copy; | |
888 } | |
889 } | 882 } |
890 | 883 |
891 void NetInternalsMessageHandler::IOThreadImpl::Detach() { | 884 void NetInternalsMessageHandler::IOThreadImpl::Detach() { |
892 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 885 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
893 // Unregister with network stack to observe events. | 886 // Unregister with network stack to observe events. |
894 if (net_log()) | 887 if (net_log()) |
895 net_log()->RemoveThreadSafeObserver(this); | 888 net_log()->RemoveThreadSafeObserver(this); |
896 | 889 |
897 // Cancel any in-progress connection tests. | 890 // Cancel any in-progress connection tests. |
898 connection_tester_.reset(); | 891 connection_tester_.reset(); |
(...skipping 13 matching lines...) Expand all Loading... | |
912 | 905 |
913 if (!net_log()) { | 906 if (!net_log()) { |
914 // Register with network stack to observe events. | 907 // Register with network stack to observe events. |
915 io_thread_->net_log()->AddThreadSafeObserver(this, | 908 io_thread_->net_log()->AddThreadSafeObserver(this, |
916 net::NetLog::LOG_ALL_BUT_BYTES); | 909 net::NetLog::LOG_ALL_BUT_BYTES); |
917 } | 910 } |
918 } | 911 } |
919 | 912 |
920 void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( | 913 void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( |
921 const ListValue* list) { | 914 const ListValue* list) { |
915 DCHECK(!list); | |
922 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 916 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
923 net::ProxyService* proxy_service = context->proxy_service(); | 917 net::ProxyService* proxy_service = context->proxy_service(); |
924 | 918 |
925 DictionaryValue* dict = new DictionaryValue(); | 919 DictionaryValue* dict = new DictionaryValue(); |
926 if (proxy_service->fetched_config().is_valid()) | 920 if (proxy_service->fetched_config().is_valid()) |
927 dict->Set("original", proxy_service->fetched_config().ToValue()); | 921 dict->Set("original", proxy_service->fetched_config().ToValue()); |
928 if (proxy_service->config().is_valid()) | 922 if (proxy_service->config().is_valid()) |
929 dict->Set("effective", proxy_service->config().ToValue()); | 923 dict->Set("effective", proxy_service->config().ToValue()); |
930 | 924 |
931 SendJavascriptCommand("receivedProxySettings", dict); | 925 SendJavascriptCommand("receivedProxySettings", dict); |
932 } | 926 } |
933 | 927 |
934 void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( | 928 void NetInternalsMessageHandler::IOThreadImpl::OnReloadProxySettings( |
935 const ListValue* list) { | 929 const ListValue* list) { |
930 DCHECK(!list); | |
936 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 931 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
937 context->proxy_service()->ForceReloadProxyConfig(); | 932 context->proxy_service()->ForceReloadProxyConfig(); |
938 | 933 |
939 // Cause the renderer to be notified of the new values. | 934 // Cause the renderer to be notified of the new values. |
940 OnGetProxySettings(NULL); | 935 OnGetProxySettings(NULL); |
941 } | 936 } |
942 | 937 |
943 void NetInternalsMessageHandler::IOThreadImpl::OnGetBadProxies( | 938 void NetInternalsMessageHandler::IOThreadImpl::OnGetBadProxies( |
944 const ListValue* list) { | 939 const ListValue* list) { |
940 DCHECK(!list); | |
945 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 941 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
946 | 942 |
947 const net::ProxyRetryInfoMap& bad_proxies_map = | 943 const net::ProxyRetryInfoMap& bad_proxies_map = |
948 context->proxy_service()->proxy_retry_info(); | 944 context->proxy_service()->proxy_retry_info(); |
949 | 945 |
950 ListValue* dict_list = new ListValue(); | 946 ListValue* dict_list = new ListValue(); |
951 | 947 |
952 for (net::ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); | 948 for (net::ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); |
953 it != bad_proxies_map.end(); ++it) { | 949 it != bad_proxies_map.end(); ++it) { |
954 const std::string& proxy_uri = it->first; | 950 const std::string& proxy_uri = it->first; |
955 const net::ProxyRetryInfo& retry_info = it->second; | 951 const net::ProxyRetryInfo& retry_info = it->second; |
956 | 952 |
957 DictionaryValue* dict = new DictionaryValue(); | 953 DictionaryValue* dict = new DictionaryValue(); |
958 dict->SetString("proxy_uri", proxy_uri); | 954 dict->SetString("proxy_uri", proxy_uri); |
959 dict->SetString("bad_until", | 955 dict->SetString("bad_until", |
960 net::NetLog::TickCountToString(retry_info.bad_until)); | 956 net::NetLog::TickCountToString(retry_info.bad_until)); |
961 | 957 |
962 dict_list->Append(dict); | 958 dict_list->Append(dict); |
963 } | 959 } |
964 | 960 |
965 SendJavascriptCommand("receivedBadProxies", dict_list); | 961 SendJavascriptCommand("receivedBadProxies", dict_list); |
966 } | 962 } |
967 | 963 |
968 void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( | 964 void NetInternalsMessageHandler::IOThreadImpl::OnClearBadProxies( |
969 const ListValue* list) { | 965 const ListValue* list) { |
966 DCHECK(!list); | |
970 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 967 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
971 context->proxy_service()->ClearBadProxiesCache(); | 968 context->proxy_service()->ClearBadProxiesCache(); |
972 | 969 |
973 // Cause the renderer to be notified of the new values. | 970 // Cause the renderer to be notified of the new values. |
974 OnGetBadProxies(NULL); | 971 OnGetBadProxies(NULL); |
975 } | 972 } |
976 | 973 |
977 void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( | 974 void NetInternalsMessageHandler::IOThreadImpl::OnGetHostResolverInfo( |
978 const ListValue* list) { | 975 const ListValue* list) { |
976 DCHECK(!list); | |
979 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 977 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
980 net::HostCache* cache = GetHostResolverCache(context); | 978 net::HostCache* cache = GetHostResolverCache(context); |
981 | 979 |
982 if (!cache) { | 980 if (!cache) { |
983 SendJavascriptCommand("receivedHostResolverInfo", NULL); | 981 SendJavascriptCommand("receivedHostResolverInfo", NULL); |
984 return; | 982 return; |
985 } | 983 } |
986 | 984 |
987 DictionaryValue* dict = new DictionaryValue(); | 985 DictionaryValue* dict = new DictionaryValue(); |
988 | 986 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 } | 1029 } |
1032 | 1030 |
1033 cache_info_dict->Set("entries", entry_list); | 1031 cache_info_dict->Set("entries", entry_list); |
1034 dict->Set("cache", cache_info_dict); | 1032 dict->Set("cache", cache_info_dict); |
1035 | 1033 |
1036 SendJavascriptCommand("receivedHostResolverInfo", dict); | 1034 SendJavascriptCommand("receivedHostResolverInfo", dict); |
1037 } | 1035 } |
1038 | 1036 |
1039 void NetInternalsMessageHandler::IOThreadImpl::OnRunIPv6Probe( | 1037 void NetInternalsMessageHandler::IOThreadImpl::OnRunIPv6Probe( |
1040 const ListValue* list) { | 1038 const ListValue* list) { |
1039 DCHECK(!list); | |
1041 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 1040 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
1042 net::HostResolver* resolver = context->host_resolver(); | 1041 net::HostResolver* resolver = context->host_resolver(); |
1043 | 1042 |
1044 // Have to set the default address family manually before calling | 1043 // Have to set the default address family manually before calling |
1045 // ProbeIPv6Support. | 1044 // ProbeIPv6Support. |
1046 resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); | 1045 resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); |
1047 resolver->ProbeIPv6Support(); | 1046 resolver->ProbeIPv6Support(); |
1048 } | 1047 } |
1049 | 1048 |
1050 void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( | 1049 void NetInternalsMessageHandler::IOThreadImpl::OnClearHostResolverCache( |
1051 const ListValue* list) { | 1050 const ListValue* list) { |
1051 DCHECK(!list); | |
1052 net::HostCache* cache = | 1052 net::HostCache* cache = |
1053 GetHostResolverCache(context_getter_->GetURLRequestContext()); | 1053 GetHostResolverCache(context_getter_->GetURLRequestContext()); |
1054 | 1054 |
1055 if (cache) | 1055 if (cache) |
1056 cache->clear(); | 1056 cache->clear(); |
1057 | 1057 |
1058 // Cause the renderer to be notified of the new values. | 1058 // Cause the renderer to be notified of the new values. |
1059 OnGetHostResolverInfo(NULL); | 1059 OnGetHostResolverInfo(NULL); |
1060 } | 1060 } |
1061 | 1061 |
1062 void NetInternalsMessageHandler::IOThreadImpl::OnEnableIPv6( | 1062 void NetInternalsMessageHandler::IOThreadImpl::OnEnableIPv6( |
1063 const ListValue* list) { | 1063 const ListValue* list) { |
1064 DCHECK(!list); | |
1064 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); | 1065 net::URLRequestContext* context = context_getter_->GetURLRequestContext(); |
1065 net::HostResolver* host_resolver = context->host_resolver(); | 1066 net::HostResolver* host_resolver = context->host_resolver(); |
1066 | 1067 |
1067 host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); | 1068 host_resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_UNSPECIFIED); |
1068 | 1069 |
1069 // Cause the renderer to be notified of the new value. | 1070 // Cause the renderer to be notified of the new value. |
1070 OnGetHostResolverInfo(NULL); | 1071 OnGetHostResolverInfo(NULL); |
1071 } | 1072 } |
1072 | 1073 |
1073 void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( | 1074 void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( |
(...skipping 26 matching lines...) Expand all Loading... | |
1100 *string += ","; | 1101 *string += ","; |
1101 *string += "sha1/" + encoded; | 1102 *string += "sha1/" + encoded; |
1102 } | 1103 } |
1103 } | 1104 } |
1104 | 1105 |
1105 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( | 1106 void NetInternalsMessageHandler::IOThreadImpl::OnHSTSQuery( |
1106 const ListValue* list) { | 1107 const ListValue* list) { |
1107 // |list| should be: [<domain to query>]. | 1108 // |list| should be: [<domain to query>]. |
1108 std::string domain; | 1109 std::string domain; |
1109 CHECK(list->GetString(0, &domain)); | 1110 CHECK(list->GetString(0, &domain)); |
1110 DictionaryValue* result = new(DictionaryValue); | 1111 DictionaryValue* result = new DictionaryValue(); |
1111 | 1112 |
1112 if (!IsStringASCII(domain)) { | 1113 if (!IsStringASCII(domain)) { |
1113 result->SetString("error", "non-ASCII domain name"); | 1114 result->SetString("error", "non-ASCII domain name"); |
1114 } else { | 1115 } else { |
1115 net::TransportSecurityState* transport_security_state = | 1116 net::TransportSecurityState* transport_security_state = |
1116 context_getter_->GetURLRequestContext()->transport_security_state(); | 1117 context_getter_->GetURLRequestContext()->transport_security_state(); |
1117 if (!transport_security_state) { | 1118 if (!transport_security_state) { |
1118 result->SetString("error", "no TransportSecurityState active"); | 1119 result->SetString("error", "no TransportSecurityState active"); |
1119 } else { | 1120 } else { |
1120 net::TransportSecurityState::DomainState state; | 1121 net::TransportSecurityState::DomainState state; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1164 if (!transport_security_state) | 1165 if (!transport_security_state) |
1165 return; | 1166 return; |
1166 | 1167 |
1167 net::TransportSecurityState::DomainState state; | 1168 net::TransportSecurityState::DomainState state; |
1168 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); | 1169 state.upgrade_expiry = state.created + base::TimeDelta::FromDays(1000); |
1169 state.include_subdomains = include_subdomains; | 1170 state.include_subdomains = include_subdomains; |
1170 if (!hashes_str.empty()) { | 1171 if (!hashes_str.empty()) { |
1171 std::vector<std::string> type_and_b64s; | 1172 std::vector<std::string> type_and_b64s; |
1172 base::SplitString(hashes_str, ',', &type_and_b64s); | 1173 base::SplitString(hashes_str, ',', &type_and_b64s); |
1173 for (std::vector<std::string>::const_iterator | 1174 for (std::vector<std::string>::const_iterator |
1174 i = type_and_b64s.begin(); i != type_and_b64s.end(); i++) { | 1175 i = type_and_b64s.begin(); i != type_and_b64s.end(); ++i) { |
1175 std::string type_and_b64; | 1176 std::string type_and_b64; |
1176 RemoveChars(*i, " \t\r\n", &type_and_b64); | 1177 RemoveChars(*i, " \t\r\n", &type_and_b64); |
1177 net::SHA1Fingerprint hash; | 1178 net::SHA1Fingerprint hash; |
1178 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) | 1179 if (!net::TransportSecurityState::ParsePin(type_and_b64, &hash)) |
1179 continue; | 1180 continue; |
1180 | 1181 |
1181 state.dynamic_spki_hashes.push_back(hash); | 1182 state.dynamic_spki_hashes.push_back(hash); |
1182 } | 1183 } |
1183 } | 1184 } |
1184 | 1185 |
(...skipping 12 matching lines...) Expand all Loading... | |
1197 net::TransportSecurityState* transport_security_state = | 1198 net::TransportSecurityState* transport_security_state = |
1198 context_getter_->GetURLRequestContext()->transport_security_state(); | 1199 context_getter_->GetURLRequestContext()->transport_security_state(); |
1199 if (!transport_security_state) | 1200 if (!transport_security_state) |
1200 return; | 1201 return; |
1201 | 1202 |
1202 transport_security_state->DeleteHost(domain); | 1203 transport_security_state->DeleteHost(domain); |
1203 } | 1204 } |
1204 | 1205 |
1205 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( | 1206 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( |
1206 const ListValue* list) { | 1207 const ListValue* list) { |
1208 DCHECK(!list); | |
1207 DictionaryValue* info_dict = new DictionaryValue(); | 1209 DictionaryValue* info_dict = new DictionaryValue(); |
1208 DictionaryValue* stats_dict = new DictionaryValue(); | 1210 DictionaryValue* stats_dict = new DictionaryValue(); |
1209 | 1211 |
1210 disk_cache::Backend* disk_cache = GetDiskCacheBackend( | 1212 disk_cache::Backend* disk_cache = GetDiskCacheBackend( |
1211 context_getter_->GetURLRequestContext()); | 1213 context_getter_->GetURLRequestContext()); |
1212 | 1214 |
1213 if (disk_cache) { | 1215 if (disk_cache) { |
1214 // Extract the statistics key/value pairs from the backend. | 1216 // Extract the statistics key/value pairs from the backend. |
1215 std::vector<std::pair<std::string, std::string> > stats; | 1217 std::vector<std::pair<std::string, std::string> > stats; |
1216 disk_cache->GetStats(&stats); | 1218 disk_cache->GetStats(&stats); |
1217 for (size_t i = 0; i < stats.size(); ++i) { | 1219 for (size_t i = 0; i < stats.size(); ++i) { |
1218 stats_dict->Set(stats[i].first, | 1220 stats_dict->Set(stats[i].first, |
1219 Value::CreateStringValue(stats[i].second)); | 1221 Value::CreateStringValue(stats[i].second)); |
1220 } | 1222 } |
1221 } | 1223 } |
1222 | 1224 |
1223 info_dict->Set("stats", stats_dict); | 1225 info_dict->Set("stats", stats_dict); |
1224 | 1226 |
1225 SendJavascriptCommand("receivedHttpCacheInfo", info_dict); | 1227 SendJavascriptCommand("receivedHttpCacheInfo", info_dict); |
1226 } | 1228 } |
1227 | 1229 |
1228 void NetInternalsMessageHandler::IOThreadImpl::OnGetSocketPoolInfo( | 1230 void NetInternalsMessageHandler::IOThreadImpl::OnGetSocketPoolInfo( |
1229 const ListValue* list) { | 1231 const ListValue* list) { |
1232 DCHECK(!list); | |
1230 net::HttpNetworkSession* http_network_session = | 1233 net::HttpNetworkSession* http_network_session = |
1231 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1234 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1232 | 1235 |
1233 Value* socket_pool_info = NULL; | 1236 Value* socket_pool_info = NULL; |
1234 if (http_network_session) | 1237 if (http_network_session) |
1235 socket_pool_info = http_network_session->SocketPoolInfoToValue(); | 1238 socket_pool_info = http_network_session->SocketPoolInfoToValue(); |
1236 | 1239 |
1237 SendJavascriptCommand("receivedSocketPoolInfo", socket_pool_info); | 1240 SendJavascriptCommand("receivedSocketPoolInfo", socket_pool_info); |
1238 } | 1241 } |
1239 | 1242 |
1240 | 1243 |
1241 void NetInternalsMessageHandler::IOThreadImpl::OnFlushSocketPools( | 1244 void NetInternalsMessageHandler::IOThreadImpl::OnFlushSocketPools( |
1242 const ListValue* list) { | 1245 const ListValue* list) { |
1246 DCHECK(!list); | |
1243 net::HttpNetworkSession* http_network_session = | 1247 net::HttpNetworkSession* http_network_session = |
1244 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1248 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1245 | 1249 |
1246 if (http_network_session) | 1250 if (http_network_session) |
1247 http_network_session->CloseAllConnections(); | 1251 http_network_session->CloseAllConnections(); |
1248 } | 1252 } |
1249 | 1253 |
1250 void NetInternalsMessageHandler::IOThreadImpl::OnCloseIdleSockets( | 1254 void NetInternalsMessageHandler::IOThreadImpl::OnCloseIdleSockets( |
1251 const ListValue* list) { | 1255 const ListValue* list) { |
1256 DCHECK(!list); | |
1252 net::HttpNetworkSession* http_network_session = | 1257 net::HttpNetworkSession* http_network_session = |
1253 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1258 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1254 | 1259 |
1255 if (http_network_session) | 1260 if (http_network_session) |
1256 http_network_session->CloseIdleConnections(); | 1261 http_network_session->CloseIdleConnections(); |
1257 } | 1262 } |
1258 | 1263 |
1259 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdySessionInfo( | 1264 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdySessionInfo( |
1260 const ListValue* list) { | 1265 const ListValue* list) { |
1266 DCHECK(!list); | |
1261 net::HttpNetworkSession* http_network_session = | 1267 net::HttpNetworkSession* http_network_session = |
1262 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1268 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1263 | 1269 |
1264 Value* spdy_info = NULL; | 1270 Value* spdy_info = http_network_session ? |
1265 if (http_network_session) { | 1271 http_network_session->SpdySessionPoolInfoToValue() : NULL; |
1266 spdy_info = http_network_session->SpdySessionPoolInfoToValue(); | |
1267 } | |
1268 | |
1269 SendJavascriptCommand("receivedSpdySessionInfo", spdy_info); | 1272 SendJavascriptCommand("receivedSpdySessionInfo", spdy_info); |
1270 } | 1273 } |
1271 | 1274 |
1272 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus( | 1275 void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus( |
1273 const ListValue* list) { | 1276 const ListValue* list) { |
1277 DCHECK(!list); | |
1274 DictionaryValue* status_dict = new DictionaryValue(); | 1278 DictionaryValue* status_dict = new DictionaryValue(); |
1275 | 1279 |
1276 status_dict->Set("spdy_enabled", | 1280 status_dict->Set("spdy_enabled", |
1277 Value::CreateBooleanValue( | 1281 Value::CreateBooleanValue( |
1278 net::HttpStreamFactory::spdy_enabled())); | 1282 net::HttpStreamFactory::spdy_enabled())); |
1279 status_dict->Set("use_alternate_protocols", | 1283 status_dict->Set("use_alternate_protocols", |
1280 Value::CreateBooleanValue( | 1284 Value::CreateBooleanValue( |
1281 net::HttpStreamFactory::use_alternate_protocols())); | 1285 net::HttpStreamFactory::use_alternate_protocols())); |
1282 status_dict->Set("force_spdy_over_ssl", | 1286 status_dict->Set("force_spdy_over_ssl", |
1283 Value::CreateBooleanValue( | 1287 Value::CreateBooleanValue( |
(...skipping 11 matching lines...) Expand all Loading... | |
1295 next_protos_value = Value::CreateStringValue(""); | 1299 next_protos_value = Value::CreateStringValue(""); |
1296 } | 1300 } |
1297 status_dict->Set("next_protos", next_protos_value); | 1301 status_dict->Set("next_protos", next_protos_value); |
1298 | 1302 |
1299 SendJavascriptCommand("receivedSpdyStatus", status_dict); | 1303 SendJavascriptCommand("receivedSpdyStatus", status_dict); |
1300 } | 1304 } |
1301 | 1305 |
1302 void | 1306 void |
1303 NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings( | 1307 NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings( |
1304 const ListValue* list) { | 1308 const ListValue* list) { |
1309 DCHECK(!list); | |
1305 ListValue* dict_list = new ListValue(); | 1310 ListValue* dict_list = new ListValue(); |
1306 | 1311 |
1307 const net::HttpServerProperties& http_server_properties = | 1312 const net::HttpServerProperties& http_server_properties = |
1308 *context_getter_->GetURLRequestContext()->http_server_properties(); | 1313 *context_getter_->GetURLRequestContext()->http_server_properties(); |
1309 | 1314 |
1310 const net::AlternateProtocolMap& map = | 1315 const net::AlternateProtocolMap& map = |
1311 http_server_properties.alternate_protocol_map(); | 1316 http_server_properties.alternate_protocol_map(); |
1312 | 1317 |
1313 for (net::AlternateProtocolMap::const_iterator it = map.begin(); | 1318 for (net::AlternateProtocolMap::const_iterator it = map.begin(); |
1314 it != map.end(); ++it) { | 1319 it != map.end(); ++it) { |
1315 DictionaryValue* dict = new DictionaryValue(); | 1320 DictionaryValue* dict = new DictionaryValue(); |
1316 dict->SetString("host_port_pair", it->first.ToString()); | 1321 dict->SetString("host_port_pair", it->first.ToString()); |
1317 dict->SetString("alternate_protocol", it->second.ToString()); | 1322 dict->SetString("alternate_protocol", it->second.ToString()); |
1318 dict_list->Append(dict); | 1323 dict_list->Append(dict); |
1319 } | 1324 } |
1320 | 1325 |
1321 SendJavascriptCommand("receivedSpdyAlternateProtocolMappings", dict_list); | 1326 SendJavascriptCommand("receivedSpdyAlternateProtocolMappings", dict_list); |
1322 } | 1327 } |
1323 | 1328 |
1324 #ifdef OS_WIN | 1329 #if defined(OS_WIN) |
1325 void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( | 1330 void NetInternalsMessageHandler::IOThreadImpl::OnGetServiceProviders( |
1326 const ListValue* list) { | 1331 const ListValue* list) { |
1332 DCHECK(!list); | |
1327 | 1333 |
1328 DictionaryValue* service_providers = new DictionaryValue(); | 1334 DictionaryValue* service_providers = new DictionaryValue(); |
1329 | 1335 |
1330 WinsockLayeredServiceProviderList layered_providers; | 1336 WinsockLayeredServiceProviderList layered_providers; |
1331 GetWinsockLayeredServiceProviders(&layered_providers); | 1337 GetWinsockLayeredServiceProviders(&layered_providers); |
1332 ListValue* layered_provider_list = new ListValue(); | 1338 ListValue* layered_provider_list = new ListValue(); |
1333 for (size_t i = 0; i < layered_providers.size(); ++i) { | 1339 for (size_t i = 0; i < layered_providers.size(); ++i) { |
1334 DictionaryValue* service_dict = new DictionaryValue(); | 1340 DictionaryValue* service_dict = new DictionaryValue(); |
1335 service_dict->SetString("name", layered_providers[i].name); | 1341 service_dict->SetString("name", layered_providers[i].name); |
1336 service_dict->SetInteger("version", layered_providers[i].version); | 1342 service_dict->SetInteger("version", layered_providers[i].version); |
(...skipping 18 matching lines...) Expand all Loading... | |
1355 namespace_dict->SetInteger("type", namespace_providers[i].type); | 1361 namespace_dict->SetInteger("type", namespace_providers[i].type); |
1356 | 1362 |
1357 namespace_list->Append(namespace_dict); | 1363 namespace_list->Append(namespace_dict); |
1358 } | 1364 } |
1359 service_providers->Set("namespace_providers", namespace_list); | 1365 service_providers->Set("namespace_providers", namespace_list); |
1360 | 1366 |
1361 SendJavascriptCommand("receivedServiceProviders", service_providers); | 1367 SendJavascriptCommand("receivedServiceProviders", service_providers); |
1362 } | 1368 } |
1363 #endif | 1369 #endif |
1364 | 1370 |
1365 #ifdef OS_CHROMEOS | 1371 #if defined(OS_CHROMEOS) |
1366 void NetInternalsMessageHandler::OnRefreshSystemLogs(const ListValue* list) { | 1372 void NetInternalsMessageHandler::OnRefreshSystemLogs(const ListValue* list) { |
1373 DCHECK(!list); | |
1367 DCHECK(syslogs_getter_.get()); | 1374 DCHECK(syslogs_getter_.get()); |
1368 syslogs_getter_->DeleteSystemLogs(); | 1375 syslogs_getter_->DeleteSystemLogs(); |
1369 syslogs_getter_->LoadSystemLogs(); | 1376 syslogs_getter_->LoadSystemLogs(); |
1370 } | 1377 } |
1371 | 1378 |
1372 void NetInternalsMessageHandler::OnGetSystemLog(const ListValue* list) { | 1379 void NetInternalsMessageHandler::OnGetSystemLog(const ListValue* list) { |
1373 DCHECK(syslogs_getter_.get()); | 1380 DCHECK(syslogs_getter_.get()); |
1374 syslogs_getter_->RequestSystemLog(list); | 1381 syslogs_getter_->RequestSystemLog(list); |
1375 } | 1382 } |
1376 | 1383 |
(...skipping 15 matching lines...) Expand all Loading... | |
1392 | 1399 |
1393 // Now that we've added the networks, we need to rescan them so they'll be | 1400 // Now that we've added the networks, we need to rescan them so they'll be |
1394 // available from the menu more immediately. | 1401 // available from the menu more immediately. |
1395 cros_network->RequestNetworkScan(); | 1402 cros_network->RequestNetworkScan(); |
1396 | 1403 |
1397 SendJavascriptCommand("receivedONCFileParse", | 1404 SendJavascriptCommand("receivedONCFileParse", |
1398 Value::CreateStringValue(error)); | 1405 Value::CreateStringValue(error)); |
1399 } | 1406 } |
1400 | 1407 |
1401 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { | 1408 void NetInternalsMessageHandler::OnStoreDebugLogs(const ListValue* list) { |
1409 DCHECK(!list); | |
1402 StoreDebugLogs( | 1410 StoreDebugLogs( |
1403 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, | 1411 base::Bind(&NetInternalsMessageHandler::OnStoreDebugLogsCompleted, |
1404 AsWeakPtr())); | 1412 AsWeakPtr())); |
1405 } | 1413 } |
1406 | 1414 |
1407 void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( | 1415 void NetInternalsMessageHandler::OnStoreDebugLogsCompleted( |
1408 const FilePath& log_path, bool succeeded) { | 1416 const FilePath& log_path, bool succeeded) { |
1409 std::string status; | 1417 std::string status; |
1410 if (succeeded) | 1418 if (succeeded) |
1411 status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe(); | 1419 status = "Created log file: " + log_path.BaseName().AsUTF8Unsafe(); |
(...skipping 20 matching lines...) Expand all Loading... | |
1432 const std::string& subsystem, | 1440 const std::string& subsystem, |
1433 bool succeeded) { | 1441 bool succeeded) { |
1434 std::string status; | 1442 std::string status; |
1435 if (succeeded) | 1443 if (succeeded) |
1436 status = "Debug mode is changed to " + subsystem; | 1444 status = "Debug mode is changed to " + subsystem; |
1437 else | 1445 else |
1438 status = "Failed to change debug mode to " + subsystem; | 1446 status = "Failed to change debug mode to " + subsystem; |
1439 SendJavascriptCommand("receivedSetNetworkDebugMode", | 1447 SendJavascriptCommand("receivedSetNetworkDebugMode", |
1440 Value::CreateStringValue(status)); | 1448 Value::CreateStringValue(status)); |
1441 } | 1449 } |
1442 #endif | 1450 #endif // defined(OS_CHROMEOS) |
1443 | 1451 |
1444 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus( | 1452 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus( |
1445 const ListValue* list) { | 1453 const ListValue* list) { |
1454 DCHECK(!list); | |
1446 DictionaryValue* status_dict = new DictionaryValue(); | 1455 DictionaryValue* status_dict = new DictionaryValue(); |
1447 | 1456 |
1448 status_dict->Set("pipelining_enabled", | 1457 status_dict->Set("pipelining_enabled", |
1449 Value::CreateBooleanValue( | 1458 Value::CreateBooleanValue( |
1450 net::HttpStreamFactory::http_pipelining_enabled())); | 1459 net::HttpStreamFactory::http_pipelining_enabled())); |
1451 | 1460 |
1452 net::HttpNetworkSession* http_network_session = | 1461 net::HttpNetworkSession* http_network_session = |
1453 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); | 1462 GetHttpNetworkSession(context_getter_->GetURLRequestContext()); |
1454 Value* pipelined_connection_info = NULL; | 1463 Value* pipelined_connection_info = NULL; |
1455 if (http_network_session) { | 1464 if (http_network_session) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1565 dict); | 1574 dict); |
1566 } | 1575 } |
1567 | 1576 |
1568 void | 1577 void |
1569 NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestSuite() { | 1578 NetInternalsMessageHandler::IOThreadImpl::OnCompletedConnectionTestSuite() { |
1570 SendJavascriptCommand( | 1579 SendJavascriptCommand( |
1571 "receivedCompletedConnectionTestSuite", | 1580 "receivedCompletedConnectionTestSuite", |
1572 NULL); | 1581 NULL); |
1573 } | 1582 } |
1574 | 1583 |
1575 void NetInternalsMessageHandler::IOThreadImpl::DispatchToMessageHandler( | 1584 void NetInternalsMessageHandler::IOThreadImpl::DispatchToMessageHandler( |
eroman
2012/08/01 23:10:05
Delete this, it is dead code.
| |
1576 ListValue* arg, MessageHandler method) { | 1585 ListValue* arg, MessageHandler method) { |
1577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1578 (this->*method)(arg); | 1587 (this->*method)(arg); |
1579 delete arg; | 1588 delete arg; |
1580 } | 1589 } |
1581 | 1590 |
1582 // Note that this can be called from ANY THREAD. | 1591 // Note that this can be called from ANY THREAD. |
1583 void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand( | 1592 void NetInternalsMessageHandler::IOThreadImpl::SendJavascriptCommand( |
1584 const std::string& command, | 1593 const std::string& command, |
1585 Value* arg) { | 1594 Value* arg) { |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1745 } | 1754 } |
1746 | 1755 |
1747 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1756 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
1748 : WebUIController(web_ui) { | 1757 : WebUIController(web_ui) { |
1749 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1758 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
1750 | 1759 |
1751 // Set up the chrome://net-internals/ source. | 1760 // Set up the chrome://net-internals/ source. |
1752 Profile* profile = Profile::FromWebUI(web_ui); | 1761 Profile* profile = Profile::FromWebUI(web_ui); |
1753 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); | 1762 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); |
1754 } | 1763 } |
OLD | NEW |