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 "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 <vector> | 10 #include <vector> |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // Note that under Linux, the media library will normally already have | 398 // Note that under Linux, the media library will normally already have |
399 // been initialized by the Zygote before this instance became a Renderer. | 399 // been initialized by the Zygote before this instance became a Renderer. |
400 base::FilePath media_path; | 400 base::FilePath media_path; |
401 PathService::Get(DIR_MEDIA_LIBS, &media_path); | 401 PathService::Get(DIR_MEDIA_LIBS, &media_path); |
402 if (!media_path.empty()) | 402 if (!media_path.empty()) |
403 media::InitializeMediaLibrary(media_path); | 403 media::InitializeMediaLibrary(media_path); |
404 | 404 |
405 memory_pressure_listener_.reset(new base::MemoryPressureListener( | 405 memory_pressure_listener_.reset(new base::MemoryPressureListener( |
406 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); | 406 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)))); |
407 | 407 |
408 renderer_process_id_ = base::kNullProcessId; | |
409 | |
410 std::vector<base::DiscardableMemoryType> supported_types; | 408 std::vector<base::DiscardableMemoryType> supported_types; |
411 base::DiscardableMemory::GetSupportedTypes(&supported_types); | 409 base::DiscardableMemory::GetSupportedTypes(&supported_types); |
412 DCHECK(!supported_types.empty()); | 410 DCHECK(!supported_types.empty()); |
413 | 411 |
414 // The default preferred type is always the first one in list. | 412 // The default preferred type is always the first one in list. |
415 base::DiscardableMemoryType type = supported_types[0]; | 413 base::DiscardableMemoryType type = supported_types[0]; |
416 | 414 |
417 if (command_line.HasSwitch(switches::kUseDiscardableMemory)) { | 415 if (command_line.HasSwitch(switches::kUseDiscardableMemory)) { |
418 std::string requested_type_name = command_line.GetSwitchValueASCII( | 416 std::string requested_type_name = command_line.GetSwitchValueASCII( |
419 switches::kUseDiscardableMemory); | 417 switches::kUseDiscardableMemory); |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 bool handled = true; | 1134 bool handled = true; |
1137 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) | 1135 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) |
1138 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, | 1136 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForCurrentURL, |
1139 OnSetZoomLevelForCurrentURL) | 1137 OnSetZoomLevelForCurrentURL) |
1140 // TODO(port): removed from render_messages_internal.h; | 1138 // TODO(port): removed from render_messages_internal.h; |
1141 // is there a new non-windows message I should add here? | 1139 // is there a new non-windows message I should add here? |
1142 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) | 1140 IPC_MESSAGE_HANDLER(ViewMsg_New, OnCreateNewView) |
1143 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) | 1141 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) |
1144 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged) | 1142 IPC_MESSAGE_HANDLER(ViewMsg_NetworkStateChanged, OnNetworkStateChanged) |
1145 IPC_MESSAGE_HANDLER(ViewMsg_TempCrashWithData, OnTempCrashWithData) | 1143 IPC_MESSAGE_HANDLER(ViewMsg_TempCrashWithData, OnTempCrashWithData) |
1146 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererProcessID, OnSetRendererProcessID) | |
1147 #if defined(OS_ANDROID) | 1144 #if defined(OS_ANDROID) |
1148 IPC_MESSAGE_HANDLER(ViewMsg_SetWebKitSharedTimersSuspended, | 1145 IPC_MESSAGE_HANDLER(ViewMsg_SetWebKitSharedTimersSuspended, |
1149 OnSetWebKitSharedTimersSuspended) | 1146 OnSetWebKitSharedTimersSuspended) |
1150 #endif | 1147 #endif |
1151 #if defined(OS_MACOSX) | 1148 #if defined(OS_MACOSX) |
1152 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScrollbarTheme, OnUpdateScrollbarTheme) | 1149 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScrollbarTheme, OnUpdateScrollbarTheme) |
1153 #endif | 1150 #endif |
1154 IPC_MESSAGE_UNHANDLED(handled = false) | 1151 IPC_MESSAGE_UNHANDLED(handled = false) |
1155 IPC_END_MESSAGE_MAP() | 1152 IPC_END_MESSAGE_MAP() |
1156 return handled; | 1153 return handled; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 void RenderThreadImpl::OnNetworkStateChanged(bool online) { | 1269 void RenderThreadImpl::OnNetworkStateChanged(bool online) { |
1273 EnsureWebKitInitialized(); | 1270 EnsureWebKitInitialized(); |
1274 WebNetworkStateNotifier::setOnLine(online); | 1271 WebNetworkStateNotifier::setOnLine(online); |
1275 } | 1272 } |
1276 | 1273 |
1277 void RenderThreadImpl::OnTempCrashWithData(const GURL& data) { | 1274 void RenderThreadImpl::OnTempCrashWithData(const GURL& data) { |
1278 GetContentClient()->SetActiveURL(data); | 1275 GetContentClient()->SetActiveURL(data); |
1279 CHECK(false); | 1276 CHECK(false); |
1280 } | 1277 } |
1281 | 1278 |
1282 void RenderThreadImpl::OnSetRendererProcessID(base::ProcessId process_id) { | |
1283 renderer_process_id_ = process_id; | |
1284 } | |
1285 | |
1286 #if defined(OS_ANDROID) | 1279 #if defined(OS_ANDROID) |
1287 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { | 1280 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { |
1288 if (suspend_webkit_shared_timer_) { | 1281 if (suspend_webkit_shared_timer_) { |
1289 EnsureWebKitInitialized(); | 1282 EnsureWebKitInitialized(); |
1290 if (suspend) { | 1283 if (suspend) { |
1291 webkit_platform_support_->SuspendSharedTimer(); | 1284 webkit_platform_support_->SuspendSharedTimer(); |
1292 } else { | 1285 } else { |
1293 webkit_platform_support_->ResumeSharedTimer(); | 1286 webkit_platform_support_->ResumeSharedTimer(); |
1294 } | 1287 } |
1295 } | 1288 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 new_touchscreen); | 1354 new_touchscreen); |
1362 | 1355 |
1363 } | 1356 } |
1364 | 1357 |
1365 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { | 1358 void RenderThreadImpl::SampleGamepads(blink::WebGamepads* data) { |
1366 if (!gamepad_shared_memory_reader_) | 1359 if (!gamepad_shared_memory_reader_) |
1367 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); | 1360 gamepad_shared_memory_reader_.reset(new GamepadSharedMemoryReader); |
1368 gamepad_shared_memory_reader_->SampleGamepads(*data); | 1361 gamepad_shared_memory_reader_->SampleGamepads(*data); |
1369 } | 1362 } |
1370 | 1363 |
1371 base::ProcessId RenderThreadImpl::renderer_process_id() const { | |
1372 return renderer_process_id_; | |
1373 } | |
1374 | |
1375 void RenderThreadImpl::WidgetCreated() { | 1364 void RenderThreadImpl::WidgetCreated() { |
1376 widget_count_++; | 1365 widget_count_++; |
1377 } | 1366 } |
1378 | 1367 |
1379 void RenderThreadImpl::WidgetDestroyed() { | 1368 void RenderThreadImpl::WidgetDestroyed() { |
1380 widget_count_--; | 1369 widget_count_--; |
1381 } | 1370 } |
1382 | 1371 |
1383 void RenderThreadImpl::WidgetHidden() { | 1372 void RenderThreadImpl::WidgetHidden() { |
1384 DCHECK_LT(hidden_widget_count_, widget_count_); | 1373 DCHECK_LT(hidden_widget_count_, widget_count_); |
(...skipping 16 matching lines...) Expand all Loading... |
1401 hidden_widget_count_--; | 1390 hidden_widget_count_--; |
1402 | 1391 |
1403 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { | 1392 if (!GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) { |
1404 return; | 1393 return; |
1405 } | 1394 } |
1406 | 1395 |
1407 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 1396 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
1408 } | 1397 } |
1409 | 1398 |
1410 } // namespace content | 1399 } // namespace content |
OLD | NEW |