| 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/renderer_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_impl.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" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/guid.h" | 12 #include "base/guid.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/memory_coordinator_client_registry.h" | 16 #include "base/memory/memory_coordinator_client_registry.h" |
| 17 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| 18 #include "base/memory/shared_memory.h" | 18 #include "base/memory/shared_memory.h" |
| 19 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
| 20 #include "base/numerics/safe_conversions.h" | 20 #include "base/numerics/safe_conversions.h" |
| 21 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 22 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 #include "components/url_formatter/url_formatter.h" | 26 #include "components/url_formatter/url_formatter.h" |
| 27 #include "content/child/blob_storage/webblobregistry_impl.h" | 27 #include "content/child/blob_storage/webblobregistry_impl.h" |
| 28 #include "content/child/child_process.h" |
| 28 #include "content/child/database_util.h" | 29 #include "content/child/database_util.h" |
| 29 #include "content/child/file_info_util.h" | 30 #include "content/child/file_info_util.h" |
| 30 #include "content/child/fileapi/webfilesystem_impl.h" | 31 #include "content/child/fileapi/webfilesystem_impl.h" |
| 31 #include "content/child/indexed_db/webidbfactory_impl.h" | 32 #include "content/child/indexed_db/webidbfactory_impl.h" |
| 32 #include "content/child/quota_dispatcher.h" | 33 #include "content/child/quota_dispatcher.h" |
| 33 #include "content/child/quota_message_filter.h" | 34 #include "content/child/quota_message_filter.h" |
| 34 #include "content/child/storage_util.h" | 35 #include "content/child/storage_util.h" |
| 35 #include "content/child/thread_safe_sender.h" | 36 #include "content/child/thread_safe_sender.h" |
| 36 #include "content/child/web_database_observer_impl.h" | 37 #include "content/child/web_database_observer_impl.h" |
| 37 #include "content/child/web_url_loader_impl.h" | 38 #include "content/child/web_url_loader_impl.h" |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 sudden_termination_disables_++; | 458 sudden_termination_disables_++; |
| 458 if (sudden_termination_disables_ != 1) | 459 if (sudden_termination_disables_ != 1) |
| 459 return; | 460 return; |
| 460 } | 461 } |
| 461 | 462 |
| 462 RenderThread* thread = RenderThread::Get(); | 463 RenderThread* thread = RenderThread::Get(); |
| 463 if (thread) // NULL in unittests. | 464 if (thread) // NULL in unittests. |
| 464 thread->Send(new RenderProcessHostMsg_SuddenTerminationChanged(enabled)); | 465 thread->Send(new RenderProcessHostMsg_SuddenTerminationChanged(enabled)); |
| 465 } | 466 } |
| 466 | 467 |
| 468 void RendererBlinkPlatformImpl::IncProcessRefCount() { |
| 469 if (!main_thread_->IsCurrentThread()) { |
| 470 main_thread_->GetSingleThreadTaskRunner()->PostTask( |
| 471 FROM_HERE, base::Bind(&RendererBlinkPlatformImpl::IncProcessRefCount, |
| 472 base::Unretained(this))); |
| 473 return; |
| 474 } |
| 475 SuddenTerminationChanged(false); |
| 476 ChildProcess::current()->AddRefProcess(); |
| 477 } |
| 478 |
| 479 void RendererBlinkPlatformImpl::DecProcessRefCount() { |
| 480 if (!main_thread_->IsCurrentThread()) { |
| 481 main_thread_->GetSingleThreadTaskRunner()->PostTask( |
| 482 FROM_HERE, base::Bind(&RendererBlinkPlatformImpl::DecProcessRefCount, |
| 483 base::Unretained(this))); |
| 484 return; |
| 485 } |
| 486 SuddenTerminationChanged(true); |
| 487 ChildProcess::current()->ReleaseProcess(); |
| 488 } |
| 489 |
| 467 std::unique_ptr<WebStorageNamespace> | 490 std::unique_ptr<WebStorageNamespace> |
| 468 RendererBlinkPlatformImpl::CreateLocalStorageNamespace() { | 491 RendererBlinkPlatformImpl::CreateLocalStorageNamespace() { |
| 469 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 492 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 470 switches::kMojoLocalStorage)) { | 493 switches::kMojoLocalStorage)) { |
| 471 if (!local_storage_cached_areas_) { | 494 if (!local_storage_cached_areas_) { |
| 472 local_storage_cached_areas_.reset(new LocalStorageCachedAreas( | 495 local_storage_cached_areas_.reset(new LocalStorageCachedAreas( |
| 473 RenderThreadImpl::current()->GetStoragePartitionService())); | 496 RenderThreadImpl::current()->GetStoragePartitionService())); |
| 474 } | 497 } |
| 475 return base::MakeUnique<LocalStorageNamespace>( | 498 return base::MakeUnique<LocalStorageNamespace>( |
| 476 local_storage_cached_areas_.get()); | 499 local_storage_cached_areas_.get()); |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 //------------------------------------------------------------------------------ | 1304 //------------------------------------------------------------------------------ |
| 1282 void RendererBlinkPlatformImpl::RequestPurgeMemory() { | 1305 void RendererBlinkPlatformImpl::RequestPurgeMemory() { |
| 1283 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but | 1306 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but |
| 1284 // ChildMemoryCoordinator isn't always available as it's only initialized | 1307 // ChildMemoryCoordinator isn't always available as it's only initialized |
| 1285 // when kMemoryCoordinatorV0 is enabled. | 1308 // when kMemoryCoordinatorV0 is enabled. |
| 1286 // Use ChildMemoryCoordinator when memory coordinator is always enabled. | 1309 // Use ChildMemoryCoordinator when memory coordinator is always enabled. |
| 1287 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); | 1310 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); |
| 1288 } | 1311 } |
| 1289 | 1312 |
| 1290 } // namespace content | 1313 } // namespace content |
| OLD | NEW |