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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 2613803005: [win] Enable ModuleDatabase behind a flag. (Closed)
Patch Set: Rebase. Created 3 years, 11 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 | « chrome/renderer/chrome_content_renderer_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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/bind.h" 10 #include "base/bind.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 continue_loading_cb_.Run(); 290 continue_loading_cb_.Run();
291 delete this; 291 delete this;
292 } 292 }
293 void OnDestruct() override { delete this; } 293 void OnDestruct() override { delete this; }
294 294
295 const base::Closure continue_loading_cb_; 295 const base::Closure continue_loading_cb_;
296 296
297 DISALLOW_COPY_AND_ASSIGN(MediaLoadDeferrer); 297 DISALLOW_COPY_AND_ASSIGN(MediaLoadDeferrer);
298 }; 298 };
299 299
300 #if defined(OS_WIN)
301 // Dispatches a module |event| to the provided |module_event_sink| interface.
302 // It is expected that this only be called from the IO thread. This is only
303 // safe because the underlying |module_event_sink| object is never deleted,
304 // being owned by the leaked ChromeContentRendererClient object. If this ever
305 // changes then a WeakPtr mechanism would have to be used.
306 void HandleModuleEventOnIOThread(mojom::ModuleEventSinkPtr* module_event_sink,
307 const ModuleWatcher::ModuleEvent& event) {
308 // Simply send the module load address. The browser can validate this and look
309 // up the module details on its own.
310 (*module_event_sink)
311 ->OnModuleEvent(event.event_type,
312 reinterpret_cast<uintptr_t>(event.module_load_address));
313 }
314
315 // Receives notifications from the ModuleWatcher on any thread. Bounces these
316 // over to the provided |io_task_runner| where they are subsequently dispatched
317 // to the |module_event_sink| interface.
318 void OnModuleEvent(scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
319 mojom::ModuleEventSinkPtr* module_event_sink,
320 const ModuleWatcher::ModuleEvent& event) {
321 // The Mojo interface can only be used from a single thread. Bounce tasks
322 // over to it. It is safe to pass an unretained pointer to
323 // |module_event_sink|: it is owned by a ChromeContentRendererClient, which is
324 // a leaked singleton in the process.
325 io_task_runner->PostTask(
326 FROM_HERE, base::Bind(&HandleModuleEventOnIOThread,
327 base::Unretained(module_event_sink), event));
328 }
329 #endif
330
300 } // namespace 331 } // namespace
301 332
302 ChromeContentRendererClient::ChromeContentRendererClient() 333 ChromeContentRendererClient::ChromeContentRendererClient()
303 : main_entry_time_(base::TimeTicks::Now()) { 334 : main_entry_time_(base::TimeTicks::Now()) {
304 #if BUILDFLAG(ENABLE_EXTENSIONS) 335 #if BUILDFLAG(ENABLE_EXTENSIONS)
305 extensions::ExtensionsClient::Set( 336 extensions::ExtensionsClient::Set(
306 extensions::ChromeExtensionsClient::GetInstance()); 337 extensions::ChromeExtensionsClient::GetInstance());
307 extensions::ExtensionsRendererClient::Set( 338 extensions::ExtensionsRendererClient::Set(
308 ChromeExtensionsRendererClient::GetInstance()); 339 ChromeExtensionsRendererClient::GetInstance());
309 #endif 340 #endif
(...skipping 14 matching lines...) Expand all
324 355
325 void ChromeContentRendererClient::RenderThreadStarted() { 356 void ChromeContentRendererClient::RenderThreadStarted() {
326 RenderThread* thread = RenderThread::Get(); 357 RenderThread* thread = RenderThread::Get();
327 358
328 { 359 {
329 startup_metric_utils::mojom::StartupMetricHostPtr startup_metric_host; 360 startup_metric_utils::mojom::StartupMetricHostPtr startup_metric_host;
330 thread->GetRemoteInterfaces()->GetInterface(&startup_metric_host); 361 thread->GetRemoteInterfaces()->GetInterface(&startup_metric_host);
331 startup_metric_host->RecordRendererMainEntryTime(main_entry_time_); 362 startup_metric_host->RecordRendererMainEntryTime(main_entry_time_);
332 } 363 }
333 364
365 #if defined(OS_WIN)
366 if (base::FeatureList::IsEnabled(features::kModuleDatabase)) {
367 thread->GetRemoteInterfaces()->GetInterface(&module_event_sink_);
368
369 // It is safe to pass an unretained pointer to |module_event_sink_|, as it
370 // is owned by the process singleton ChromeContentRendererClient, which is
371 // leaked.
372 module_watcher_ = ModuleWatcher::Create(
373 base::Bind(&OnModuleEvent, thread->GetIOTaskRunner(),
374 base::Unretained(&module_event_sink_)));
375 }
376 #endif
377
334 chrome_observer_.reset(new ChromeRenderThreadObserver()); 378 chrome_observer_.reset(new ChromeRenderThreadObserver());
335 web_cache_impl_.reset(new web_cache::WebCacheImpl()); 379 web_cache_impl_.reset(new web_cache::WebCacheImpl());
336 380
337 #if BUILDFLAG(ENABLE_EXTENSIONS) 381 #if BUILDFLAG(ENABLE_EXTENSIONS)
338 ChromeExtensionsRendererClient::GetInstance()->RenderThreadStarted(); 382 ChromeExtensionsRendererClient::GetInstance()->RenderThreadStarted();
339 #endif 383 #endif
340 384
341 prescient_networking_dispatcher_.reset( 385 prescient_networking_dispatcher_.reset(
342 new network_hints::PrescientNetworkingDispatcher()); 386 new network_hints::PrescientNetworkingDispatcher());
343 #if BUILDFLAG(ENABLE_SPELLCHECK) 387 #if BUILDFLAG(ENABLE_SPELLCHECK)
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 std::vector<base::SchedulerWorkerPoolParams>* params_vector, 1521 std::vector<base::SchedulerWorkerPoolParams>* params_vector,
1478 base::TaskScheduler::WorkerPoolIndexForTraitsCallback* 1522 base::TaskScheduler::WorkerPoolIndexForTraitsCallback*
1479 index_to_traits_callback) { 1523 index_to_traits_callback) {
1480 DCHECK(params_vector); 1524 DCHECK(params_vector);
1481 DCHECK(index_to_traits_callback); 1525 DCHECK(index_to_traits_callback);
1482 // If this call fails, content will fall back to the default params. 1526 // If this call fails, content will fall back to the default params.
1483 *params_vector = task_scheduler_util::GetRendererWorkerPoolParams(); 1527 *params_vector = task_scheduler_util::GetRendererWorkerPoolParams();
1484 *index_to_traits_callback = 1528 *index_to_traits_callback =
1485 base::Bind(&task_scheduler_util::RendererWorkerPoolIndexForTraits); 1529 base::Bind(&task_scheduler_util::RendererWorkerPoolIndexForTraits);
1486 } 1530 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698