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

Side by Side Diff: content/public/renderer/content_renderer_client.cc

Issue 2491823005: Initialize TaskScheduler in renderers. (Closed)
Patch Set: add dcheck Created 4 years, 1 month 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 "content/public/renderer/content_renderer_client.h" 5 #include "content/public/renderer/content_renderer_client.h"
6 6
7 #include "base/bind.h"
8 #include "base/task_scheduler/initialization_util.h"
9 #include "base/task_scheduler/scheduler_worker_pool_params.h"
10 #include "base/task_scheduler/task_traits.h"
11 #include "base/threading/platform_thread.h"
12 #include "base/time/time.h"
7 #include "cc/blimp/remote_compositor_bridge.h" 13 #include "cc/blimp/remote_compositor_bridge.h"
8 #include "content/public/renderer/media_stream_renderer_factory.h" 14 #include "content/public/renderer/media_stream_renderer_factory.h"
9 #include "media/base/renderer_factory.h" 15 #include "media/base/renderer_factory.h"
10 #include "ui/gfx/icc_profile.h" 16 #include "ui/gfx/icc_profile.h"
11 #include "url/gurl.h" 17 #include "url/gurl.h"
12 18
13 namespace content { 19 namespace content {
14 20
21 namespace {
22
23 enum WorkerPoolType : size_t {
24 BACKGROUND_WORKER_POOL = 0,
25 FOREGROUND_WORKER_POOL,
gab 2016/11/18 18:31:59 Not used anywhere but in GetTaskSchedulerWorkerPoo
26 WORKER_POOL_COUNT // Always last.
27 };
28
29 size_t GetTaskSchedulerWorkerPoolIndexForTraits(
30 const base::TaskTraits& traits) {
31 DCHECK(!traits.with_file_io());
32 return traits.priority() == base::TaskPriority::BACKGROUND
33 ? BACKGROUND_WORKER_POOL
34 : FOREGROUND_WORKER_POOL;
35 }
gab 2016/11/18 18:31:59 I'd prefer for this to be inlined in method's scop
36
37 } // namespace
38
15 SkBitmap* ContentRendererClient::GetSadPluginBitmap() { 39 SkBitmap* ContentRendererClient::GetSadPluginBitmap() {
16 return nullptr; 40 return nullptr;
17 } 41 }
18 42
19 SkBitmap* ContentRendererClient::GetSadWebViewBitmap() { 43 SkBitmap* ContentRendererClient::GetSadWebViewBitmap() {
20 return nullptr; 44 return nullptr;
21 } 45 }
22 46
23 bool ContentRendererClient::OverrideCreatePlugin( 47 bool ContentRendererClient::OverrideCreatePlugin(
24 RenderFrame* render_frame, 48 RenderFrame* render_frame,
(...skipping 12 matching lines...) Expand all
37 bool ContentRendererClient::HasErrorPage(int http_status_code, 61 bool ContentRendererClient::HasErrorPage(int http_status_code,
38 std::string* error_domain) { 62 std::string* error_domain) {
39 return false; 63 return false;
40 } 64 }
41 65
42 bool ContentRendererClient::ShouldSuppressErrorPage(RenderFrame* render_frame, 66 bool ContentRendererClient::ShouldSuppressErrorPage(RenderFrame* render_frame,
43 const GURL& url) { 67 const GURL& url) {
44 return false; 68 return false;
45 } 69 }
46 70
71 void ContentRendererClient::GetTaskSchedulerInitializationArguments(
72 std::vector<base::SchedulerWorkerPoolParams>* worker_pool_params_vector,
73 base::Callback<size_t(const base::TaskTraits& traits)>*
74 worker_pool_index_for_traits_callback,
75 bool* redirect_sequenced_worker_pool) {
76 constexpr int kBackgroundThreadsMin = 3;
77 constexpr int kBackgroundThreadsMax = 8;
78 constexpr double kBackgroundThreadsCoresMultiplier = 0.1;
79 constexpr int kBackgroundThreadsOffset = 0;
80 worker_pool_params_vector->emplace_back(
81 "RendererBackground", base::ThreadPriority::NORMAL,
82 base::SchedulerWorkerPoolParams::IORestriction::DISALLOWED,
83 base::SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY,
84 base::RecommendedMaxNumberOfThreadsInPool(
85 kBackgroundThreadsMin, kBackgroundThreadsMax,
86 kBackgroundThreadsCoresMultiplier, kBackgroundThreadsOffset),
87 base::TimeDelta::FromSeconds(30));
88
89 constexpr int kForegroundThreadsMin = 8;
90 constexpr int kForegroundThreadsMax = 32;
91 constexpr double kForegroundThreadsCoresMultiplier = 0.3;
92 constexpr int kForegroundThreadsOffset = 0;
gab 2016/11/18 18:31:59 These constants are probably too high for the rend
93 worker_pool_params_vector->emplace_back(
94 "RendererForeground", base::ThreadPriority::NORMAL,
95 base::SchedulerWorkerPoolParams::IORestriction::DISALLOWED,
96 base::SchedulerWorkerPoolParams::StandbyThreadPolicy::LAZY,
97 base::RecommendedMaxNumberOfThreadsInPool(
98 kForegroundThreadsMin, kForegroundThreadsMax,
99 kForegroundThreadsCoresMultiplier, kForegroundThreadsOffset),
100 base::TimeDelta::FromSeconds(30));
101
102 *worker_pool_index_for_traits_callback =
103 base::Bind(&GetTaskSchedulerWorkerPoolIndexForTraits);
104
105 *redirect_sequenced_worker_pool = false;
106 }
107
47 void ContentRendererClient::DeferMediaLoad( 108 void ContentRendererClient::DeferMediaLoad(
48 RenderFrame* render_frame, 109 RenderFrame* render_frame,
49 bool has_played_media_before, 110 bool has_played_media_before,
50 const base::Closure& closure) { 111 const base::Closure& closure) {
51 closure.Run(); 112 closure.Run();
52 } 113 }
53 114
54 blink::WebMediaStreamCenter* 115 blink::WebMediaStreamCenter*
55 ContentRendererClient::OverrideCreateWebMediaStreamCenter( 116 ContentRendererClient::OverrideCreateWebMediaStreamCenter(
56 blink::WebMediaStreamCenterClient* client) { 117 blink::WebMediaStreamCenterClient* client) {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 293
233 bool ContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { 294 bool ContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() {
234 return true; 295 return true;
235 } 296 }
236 297
237 GURL ContentRendererClient::OverrideFlashEmbedWithHTML(const GURL& url) { 298 GURL ContentRendererClient::OverrideFlashEmbedWithHTML(const GURL& url) {
238 return GURL(); 299 return GURL();
239 } 300 }
240 301
241 } // namespace content 302 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698