OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/child/blink_platform_impl.h" | 5 #include "content/child/blink_platform_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 // constructing the platform. | 353 // constructing the platform. |
354 BlinkPlatformImpl::BlinkPlatformImpl() | 354 BlinkPlatformImpl::BlinkPlatformImpl() |
355 : BlinkPlatformImpl(base::ThreadTaskRunnerHandle::IsSet() | 355 : BlinkPlatformImpl(base::ThreadTaskRunnerHandle::IsSet() |
356 ? base::ThreadTaskRunnerHandle::Get() | 356 ? base::ThreadTaskRunnerHandle::Get() |
357 : nullptr) { | 357 : nullptr) { |
358 } | 358 } |
359 | 359 |
360 BlinkPlatformImpl::BlinkPlatformImpl( | 360 BlinkPlatformImpl::BlinkPlatformImpl( |
361 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) | 361 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) |
362 : main_thread_task_runner_(main_thread_task_runner), | 362 : main_thread_task_runner_(main_thread_task_runner), |
363 compositor_thread_(nullptr) { | 363 compositor_thread_(nullptr), |
364 physical_memory_mb_( | |
365 static_cast<size_t>(base::SysInfo::AmountOfPhysicalMemoryMB())) { | |
kinuko
2017/05/25 05:31:27
Hum, this doesn't seem we need public platform plu
| |
364 InternalInit(); | 366 InternalInit(); |
365 } | 367 } |
366 | 368 |
367 void BlinkPlatformImpl::InternalInit() { | 369 void BlinkPlatformImpl::InternalInit() { |
368 // ChildThread may not exist in some tests. | 370 // ChildThread may not exist in some tests. |
369 if (ChildThreadImpl::current()) { | 371 if (ChildThreadImpl::current()) { |
370 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); | 372 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); |
371 notification_dispatcher_ = | 373 notification_dispatcher_ = |
372 ChildThreadImpl::current()->notification_dispatcher(); | 374 ChildThreadImpl::current()->notification_dispatcher(); |
373 } | 375 } |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 bool BlinkPlatformImpl::DatabaseSetFileSize( | 772 bool BlinkPlatformImpl::DatabaseSetFileSize( |
771 const blink::WebString& vfs_file_name, | 773 const blink::WebString& vfs_file_name, |
772 long long size) { | 774 long long size) { |
773 return false; | 775 return false; |
774 } | 776 } |
775 | 777 |
776 size_t BlinkPlatformImpl::ActualMemoryUsageMB() { | 778 size_t BlinkPlatformImpl::ActualMemoryUsageMB() { |
777 return GetMemoryUsageKB() >> 10; | 779 return GetMemoryUsageKB() >> 10; |
778 } | 780 } |
779 | 781 |
782 size_t BlinkPlatformImpl::AmountOfPhysicalMemoryMB() { | |
783 return physical_memory_mb_; | |
784 } | |
785 | |
786 void BlinkPlatformImpl::SetDevicePhysicalMemoryMBForTesting( | |
787 int64_t physical_memory_mb) { | |
788 physical_memory_mb_ = static_cast<size_t>(physical_memory_mb); | |
789 } | |
790 | |
780 size_t BlinkPlatformImpl::NumberOfProcessors() { | 791 size_t BlinkPlatformImpl::NumberOfProcessors() { |
781 return static_cast<size_t>(base::SysInfo::NumberOfProcessors()); | 792 return static_cast<size_t>(base::SysInfo::NumberOfProcessors()); |
782 } | 793 } |
783 | 794 |
784 size_t BlinkPlatformImpl::MaxDecodedImageBytes() { | 795 size_t BlinkPlatformImpl::MaxDecodedImageBytes() { |
785 #if defined(OS_ANDROID) | 796 #if defined(OS_ANDROID) |
786 if (base::SysInfo::IsLowEndDevice()) { | 797 if (base::SysInfo::IsLowEndDevice()) { |
787 // Limit image decoded size to 3M pixels on low end devices. | 798 // Limit image decoded size to 3M pixels on low end devices. |
788 // 4 is maximum number of bytes per pixel. | 799 // 4 is maximum number of bytes per pixel. |
789 return 3 * 1024 * 1024 * 4; | 800 return 3 * 1024 * 1024 * 4; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 | 862 |
852 std::unique_ptr<blink::WebFeaturePolicy> | 863 std::unique_ptr<blink::WebFeaturePolicy> |
853 BlinkPlatformImpl::DuplicateFeaturePolicyWithOrigin( | 864 BlinkPlatformImpl::DuplicateFeaturePolicyWithOrigin( |
854 const blink::WebFeaturePolicy& policy, | 865 const blink::WebFeaturePolicy& policy, |
855 const blink::WebSecurityOrigin& new_origin) { | 866 const blink::WebSecurityOrigin& new_origin) { |
856 return FeaturePolicy::CreateFromPolicyWithOrigin( | 867 return FeaturePolicy::CreateFromPolicyWithOrigin( |
857 static_cast<const FeaturePolicy&>(policy), url::Origin(new_origin)); | 868 static_cast<const FeaturePolicy&>(policy), url::Origin(new_origin)); |
858 } | 869 } |
859 | 870 |
860 } // namespace content | 871 } // namespace content |
OLD | NEW |