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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2353003004: Move ViewHostMsg_CreateWindow to mojom (Closed)
Patch Set: . Created 4 years, 2 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 | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_view_impl.cc » ('j') | 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 "content/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 using blink::WebScriptController; 218 using blink::WebScriptController;
219 using blink::WebSecurityPolicy; 219 using blink::WebSecurityPolicy;
220 using blink::WebString; 220 using blink::WebString;
221 using blink::WebView; 221 using blink::WebView;
222 using blink::scheduler::WebThreadImplForWorkerScheduler; 222 using blink::scheduler::WebThreadImplForWorkerScheduler;
223 223
224 namespace content { 224 namespace content {
225 225
226 namespace { 226 namespace {
227 227
228 const int64_t kInitialIdleHandlerDelayMs = 1000; 228 const int64_t kInitialIdleHandlerDelayMs = 1000;
229 const int64_t kLongIdleHandlerDelayMs = 30 * 1000; 229 const int64_t kLongIdleHandlerDelayMs = 30 * 1000;
230 230
231 #if defined(OS_ANDROID) 231 #if defined(OS_ANDROID)
232 // On Android, resource messages can each take ~1.5ms to dispatch on the browser 232 // On Android, resource messages can each take ~1.5ms to dispatch on the browser
233 // IO thread. Limiting the message rate to 3/frame at 60hz ensures that the 233 // IO thread. Limiting the message rate to 3/frame at 60hz ensures that the
234 // induced work takes but a fraction (~1/4) of the overall frame budget. 234 // induced work takes but a fraction (~1/4) of the overall frame budget.
235 const int kMaxResourceRequestsPerFlushWhenThrottled = 3; 235 const int kMaxResourceRequestsPerFlushWhenThrottled = 3;
236 #else 236 #else
237 const int kMaxResourceRequestsPerFlushWhenThrottled = 8; 237 const int kMaxResourceRequestsPerFlushWhenThrottled = 8;
238 #endif 238 #endif
239 const double kThrottledResourceRequestFlushPeriodS = 1. / 60.; 239 const double kThrottledResourceRequestFlushPeriodS = 1. / 60.;
240 240
241 // Maximum allocation size allowed for image scaling filters that 241 // Maximum allocation size allowed for image scaling filters that
242 // require pre-scaling. Skia will fallback to a filter that doesn't 242 // require pre-scaling. Skia will fallback to a filter that doesn't
243 // require pre-scaling if the default filter would require an 243 // require pre-scaling if the default filter would require an
244 // allocation that exceeds this limit. 244 // allocation that exceeds this limit.
245 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024; 245 const size_t kImageCacheSingleAllocationByteLimit = 64 * 1024 * 1024;
246 246
247 // Unique identifier for each output surface created. 247 // Unique identifier for each output surface created.
248 uint32_t g_next_compositor_frame_sink_id = 1; 248 uint32_t g_next_compositor_frame_sink_id = 1;
249 249
250 // An implementation of mojom::RenderMessageFilter which can be mocked out
251 // for tests which may indirectly send messages over this interface.
252 mojom::RenderMessageFilter* g_render_message_filter_for_testing;
253
250 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access 254 // Keep the global RenderThreadImpl in a TLS slot so it is impossible to access
251 // incorrectly from the wrong thread. 255 // incorrectly from the wrong thread.
252 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> > 256 base::LazyInstance<base::ThreadLocalPointer<RenderThreadImpl> >
253 lazy_tls = LAZY_INSTANCE_INITIALIZER; 257 lazy_tls = LAZY_INSTANCE_INITIALIZER;
254 258
255 // v8::MemoryPressureLevel should correspond to base::MemoryPressureListener. 259 // v8::MemoryPressureLevel should correspond to base::MemoryPressureListener.
256 static_assert(static_cast<v8::MemoryPressureLevel>( 260 static_assert(static_cast<v8::MemoryPressureLevel>(
257 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) == 261 base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_NONE) ==
258 v8::MemoryPressureLevel::kNone, "none level not align"); 262 v8::MemoryPressureLevel::kNone, "none level not align");
259 static_assert(static_cast<v8::MemoryPressureLevel>( 263 static_assert(static_cast<v8::MemoryPressureLevel>(
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 } 566 }
563 567
564 // static 568 // static
565 RenderThreadImpl* RenderThreadImpl::Create( 569 RenderThreadImpl* RenderThreadImpl::Create(
566 std::unique_ptr<base::MessageLoop> main_message_loop, 570 std::unique_ptr<base::MessageLoop> main_message_loop,
567 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler) { 571 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler) {
568 return new RenderThreadImpl(std::move(main_message_loop), 572 return new RenderThreadImpl(std::move(main_message_loop),
569 std::move(renderer_scheduler)); 573 std::move(renderer_scheduler));
570 } 574 }
571 575
576 // static
572 RenderThreadImpl* RenderThreadImpl::current() { 577 RenderThreadImpl* RenderThreadImpl::current() {
573 return lazy_tls.Pointer()->Get(); 578 return lazy_tls.Pointer()->Get();
574 } 579 }
575 580
581 // static
582 mojom::RenderMessageFilter* RenderThreadImpl::current_render_message_filter() {
583 if (g_render_message_filter_for_testing)
584 return g_render_message_filter_for_testing;
585 DCHECK(current());
586 return current()->render_message_filter();
587 }
588
589 // static
590 void RenderThreadImpl::SetRenderMessageFilterForTesting(
591 mojom::RenderMessageFilter* render_message_filter) {
592 g_render_message_filter_for_testing = render_message_filter;
593 }
594
576 RenderThreadImpl::RenderThreadImpl( 595 RenderThreadImpl::RenderThreadImpl(
577 const InProcessChildThreadParams& params, 596 const InProcessChildThreadParams& params,
578 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler, 597 std::unique_ptr<blink::scheduler::RendererScheduler> scheduler,
579 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue) 598 scoped_refptr<base::SingleThreadTaskRunner>& resource_task_queue)
580 : ChildThreadImpl(Options::Builder() 599 : ChildThreadImpl(Options::Builder()
581 .InBrowserProcess(params) 600 .InBrowserProcess(params)
582 .UseMojoChannel(true) 601 .UseMojoChannel(true)
583 .AutoStartMojoShellConnection(false) 602 .AutoStartMojoShellConnection(false)
584 .ConnectToBrowser(true) 603 .ConnectToBrowser(true)
585 .Build()), 604 .Build()),
(...skipping 1705 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 if (blink::mainThreadIsolate()) { 2310 if (blink::mainThreadIsolate()) {
2292 blink::mainThreadIsolate()->MemoryPressureNotification( 2311 blink::mainThreadIsolate()->MemoryPressureNotification(
2293 v8::MemoryPressureLevel::kCritical); 2312 v8::MemoryPressureLevel::kCritical);
2294 blink::MemoryPressureNotificationToWorkerThreadIsolates( 2313 blink::MemoryPressureNotificationToWorkerThreadIsolates(
2295 v8::MemoryPressureLevel::kCritical); 2314 v8::MemoryPressureLevel::kCritical);
2296 } 2315 }
2297 } 2316 }
2298 2317
2299 2318
2300 } // namespace content 2319 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | content/renderer/render_view_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698