| 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/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 continue_loading_cb_.Run(); | 287 continue_loading_cb_.Run(); |
| 288 delete this; | 288 delete this; |
| 289 } | 289 } |
| 290 void OnDestruct() override { delete this; } | 290 void OnDestruct() override { delete this; } |
| 291 | 291 |
| 292 const base::Closure continue_loading_cb_; | 292 const base::Closure continue_loading_cb_; |
| 293 | 293 |
| 294 DISALLOW_COPY_AND_ASSIGN(MediaLoadDeferrer); | 294 DISALLOW_COPY_AND_ASSIGN(MediaLoadDeferrer); |
| 295 }; | 295 }; |
| 296 | 296 |
| 297 #if defined(OS_WIN) |
| 298 // Dispatches a module |event| to the provided |module_event_sink| interface. |
| 299 // It is expected that this only be called from the IO thread. This is only |
| 300 // safe because the underlying |module_event_sink| object is never deleted, |
| 301 // being owned by the leaked ChromeContentRendererClient object. If this ever |
| 302 // changes then a WeakPtr mechanism would have to be used. |
| 303 void HandleModuleEventOnIOThread(mojom::ModuleEventSinkPtr* module_event_sink, |
| 304 const ModuleWatcher::ModuleEvent& event) { |
| 305 // Simply send the module load address. The browser can validate this and look |
| 306 // up the module details on its own. |
| 307 (*module_event_sink) |
| 308 ->OnModuleEvent(event.event_type, |
| 309 reinterpret_cast<uintptr_t>(event.module_load_address)); |
| 310 } |
| 311 |
| 312 // Receives notifications from the ModuleWatcher on any thread. Bounces these |
| 313 // over to the provided |io_task_runner| where they are subsequently dispatched |
| 314 // to the |module_event_sink| interface. |
| 315 void OnModuleEvent(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 316 mojom::ModuleEventSinkPtr* module_event_sink, |
| 317 const ModuleWatcher::ModuleEvent& event) { |
| 318 // The Mojo interface can only be used from a single thread. Bounce tasks |
| 319 // over to it. |
| 320 io_task_runner->PostTask( |
| 321 FROM_HERE, base::Bind(&HandleModuleEventOnIOThread, |
| 322 base::Unretained(module_event_sink), event)); |
| 323 } |
| 324 #endif |
| 325 |
| 297 } // namespace | 326 } // namespace |
| 298 | 327 |
| 299 ChromeContentRendererClient::ChromeContentRendererClient() | 328 ChromeContentRendererClient::ChromeContentRendererClient() |
| 300 : main_entry_time_(base::TimeTicks::Now()) { | 329 : main_entry_time_(base::TimeTicks::Now()) { |
| 301 #if BUILDFLAG(ENABLE_EXTENSIONS) | 330 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 302 extensions::ExtensionsClient::Set( | 331 extensions::ExtensionsClient::Set( |
| 303 extensions::ChromeExtensionsClient::GetInstance()); | 332 extensions::ChromeExtensionsClient::GetInstance()); |
| 304 extensions::ExtensionsRendererClient::Set( | 333 extensions::ExtensionsRendererClient::Set( |
| 305 ChromeExtensionsRendererClient::GetInstance()); | 334 ChromeExtensionsRendererClient::GetInstance()); |
| 306 #endif | 335 #endif |
| (...skipping 14 matching lines...) Expand all Loading... |
| 321 | 350 |
| 322 void ChromeContentRendererClient::RenderThreadStarted() { | 351 void ChromeContentRendererClient::RenderThreadStarted() { |
| 323 RenderThread* thread = RenderThread::Get(); | 352 RenderThread* thread = RenderThread::Get(); |
| 324 | 353 |
| 325 { | 354 { |
| 326 startup_metric_utils::mojom::StartupMetricHostPtr startup_metric_host; | 355 startup_metric_utils::mojom::StartupMetricHostPtr startup_metric_host; |
| 327 thread->GetRemoteInterfaces()->GetInterface(&startup_metric_host); | 356 thread->GetRemoteInterfaces()->GetInterface(&startup_metric_host); |
| 328 startup_metric_host->RecordRendererMainEntryTime(main_entry_time_); | 357 startup_metric_host->RecordRendererMainEntryTime(main_entry_time_); |
| 329 } | 358 } |
| 330 | 359 |
| 360 #if defined(OS_WIN) |
| 361 if (base::FeatureList::IsEnabled(features::kModuleDatabase)) { |
| 362 thread->GetRemoteInterfaces()->GetInterface(&module_event_sink_); |
| 363 module_watcher_ = ModuleWatcher::Create( |
| 364 base::Bind(&OnModuleEvent, thread->GetIOTaskRunner(), |
| 365 base::Unretained(&module_event_sink_))); |
| 366 } |
| 367 #endif |
| 368 |
| 331 chrome_observer_.reset(new ChromeRenderThreadObserver()); | 369 chrome_observer_.reset(new ChromeRenderThreadObserver()); |
| 332 web_cache_impl_.reset(new web_cache::WebCacheImpl()); | 370 web_cache_impl_.reset(new web_cache::WebCacheImpl()); |
| 333 | 371 |
| 334 #if BUILDFLAG(ENABLE_EXTENSIONS) | 372 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 335 ChromeExtensionsRendererClient::GetInstance()->RenderThreadStarted(); | 373 ChromeExtensionsRendererClient::GetInstance()->RenderThreadStarted(); |
| 336 #endif | 374 #endif |
| 337 | 375 |
| 338 prescient_networking_dispatcher_.reset( | 376 prescient_networking_dispatcher_.reset( |
| 339 new network_hints::PrescientNetworkingDispatcher()); | 377 new network_hints::PrescientNetworkingDispatcher()); |
| 340 #if BUILDFLAG(ENABLE_SPELLCHECK) | 378 #if BUILDFLAG(ENABLE_SPELLCHECK) |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 | 1504 |
| 1467 url::Replacements<char> r; | 1505 url::Replacements<char> r; |
| 1468 r.SetPath(path.c_str(), url::Component(0, path.length())); | 1506 r.SetPath(path.c_str(), url::Component(0, path.length())); |
| 1469 | 1507 |
| 1470 if (result == internal::NUM_PLUGIN_ERROR) | 1508 if (result == internal::NUM_PLUGIN_ERROR) |
| 1471 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; | 1509 result = invalid_url ? internal::SUCCESS_PARAMS_REWRITE : internal::SUCCESS; |
| 1472 | 1510 |
| 1473 RecordYouTubeRewriteUMA(result); | 1511 RecordYouTubeRewriteUMA(result); |
| 1474 return corrected_url.ReplaceComponents(r); | 1512 return corrected_url.ReplaceComponents(r); |
| 1475 } | 1513 } |
| OLD | NEW |