| 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 "webkit/child/webkitplatformsupport_impl.h" | 5 #include "webkit/child/webkitplatformsupport_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "webkit/child/webkit_child_helpers.h" | 48 #include "webkit/child/webkit_child_helpers.h" |
| 49 #include "webkit/child/websocketstreamhandle_impl.h" | 49 #include "webkit/child/websocketstreamhandle_impl.h" |
| 50 #include "webkit/child/weburlloader_impl.h" | 50 #include "webkit/child/weburlloader_impl.h" |
| 51 #include "webkit/common/user_agent/user_agent.h" | 51 #include "webkit/common/user_agent/user_agent.h" |
| 52 #include "webkit/glue/webkit_glue.h" | 52 #include "webkit/glue/webkit_glue.h" |
| 53 | 53 |
| 54 #if defined(OS_ANDROID) | 54 #if defined(OS_ANDROID) |
| 55 #include "base/android/sys_utils.h" | 55 #include "base/android/sys_utils.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 using WebKit::WebAudioBus; | 58 using blink::WebAudioBus; |
| 59 using WebKit::WebCookie; | 59 using blink::WebCookie; |
| 60 using WebKit::WebData; | 60 using blink::WebData; |
| 61 using WebKit::WebLocalizedString; | 61 using blink::WebLocalizedString; |
| 62 using WebKit::WebPluginListBuilder; | 62 using blink::WebPluginListBuilder; |
| 63 using WebKit::WebString; | 63 using blink::WebString; |
| 64 using WebKit::WebSocketStreamHandle; | 64 using blink::WebSocketStreamHandle; |
| 65 using WebKit::WebURL; | 65 using blink::WebURL; |
| 66 using WebKit::WebURLError; | 66 using blink::WebURLError; |
| 67 using WebKit::WebURLLoader; | 67 using blink::WebURLLoader; |
| 68 using WebKit::WebVector; | 68 using blink::WebVector; |
| 69 | 69 |
| 70 namespace { | 70 namespace { |
| 71 | 71 |
| 72 // A simple class to cache the memory usage for a given amount of time. | 72 // A simple class to cache the memory usage for a given amount of time. |
| 73 class MemoryUsageCache { | 73 class MemoryUsageCache { |
| 74 public: | 74 public: |
| 75 // Retrieves the Singleton. | 75 // Retrieves the Singleton. |
| 76 static MemoryUsageCache* GetInstance() { | 76 static MemoryUsageCache* GetInstance() { |
| 77 return Singleton<MemoryUsageCache>::get(); | 77 return Singleton<MemoryUsageCache>::get(); |
| 78 } | 78 } |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(1)); | 462 return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(1)); |
| 463 case 2: | 463 case 2: |
| 464 return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(2)); | 464 return reinterpret_cast<long*>(&TRACE_EVENT_API_THREAD_BUCKET(2)); |
| 465 default: | 465 default: |
| 466 NOTREACHED() << "Unknown thread bucket type."; | 466 NOTREACHED() << "Unknown thread bucket type."; |
| 467 } | 467 } |
| 468 return NULL; | 468 return NULL; |
| 469 } | 469 } |
| 470 | 470 |
| 471 COMPILE_ASSERT( | 471 COMPILE_ASSERT( |
| 472 sizeof(WebKit::Platform::TraceEventHandle) == | 472 sizeof(blink::Platform::TraceEventHandle) == |
| 473 sizeof(base::debug::TraceEventHandle), | 473 sizeof(base::debug::TraceEventHandle), |
| 474 TraceEventHandle_types_must_be_same_size); | 474 TraceEventHandle_types_must_be_same_size); |
| 475 | 475 |
| 476 WebKit::Platform::TraceEventHandle WebKitPlatformSupportImpl::addTraceEvent( | 476 blink::Platform::TraceEventHandle WebKitPlatformSupportImpl::addTraceEvent( |
| 477 char phase, | 477 char phase, |
| 478 const unsigned char* category_group_enabled, | 478 const unsigned char* category_group_enabled, |
| 479 const char* name, | 479 const char* name, |
| 480 unsigned long long id, | 480 unsigned long long id, |
| 481 int num_args, | 481 int num_args, |
| 482 const char** arg_names, | 482 const char** arg_names, |
| 483 const unsigned char* arg_types, | 483 const unsigned char* arg_types, |
| 484 const unsigned long long* arg_values, | 484 const unsigned long long* arg_values, |
| 485 unsigned char flags) { | 485 unsigned char flags) { |
| 486 base::debug::TraceEventHandle handle = TRACE_EVENT_API_ADD_TRACE_EVENT( | 486 base::debug::TraceEventHandle handle = TRACE_EVENT_API_ADD_TRACE_EVENT( |
| 487 phase, category_group_enabled, name, id, | 487 phase, category_group_enabled, name, id, |
| 488 num_args, arg_names, arg_types, arg_values, NULL, flags); | 488 num_args, arg_names, arg_types, arg_values, NULL, flags); |
| 489 WebKit::Platform::TraceEventHandle result; | 489 blink::Platform::TraceEventHandle result; |
| 490 memcpy(&result, &handle, sizeof(result)); | 490 memcpy(&result, &handle, sizeof(result)); |
| 491 return result; | 491 return result; |
| 492 } | 492 } |
| 493 | 493 |
| 494 void WebKitPlatformSupportImpl::updateTraceEventDuration( | 494 void WebKitPlatformSupportImpl::updateTraceEventDuration( |
| 495 TraceEventHandle handle) { | 495 TraceEventHandle handle) { |
| 496 base::debug::TraceEventHandle traceEventHandle; | 496 base::debug::TraceEventHandle traceEventHandle; |
| 497 memcpy(&traceEventHandle, &handle, sizeof(handle)); | 497 memcpy(&traceEventHandle, &handle, sizeof(handle)); |
| 498 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(traceEventHandle); | 498 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(traceEventHandle); |
| 499 } | 499 } |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 void WebKitPlatformSupportImpl::stopSharedTimer() { | 787 void WebKitPlatformSupportImpl::stopSharedTimer() { |
| 788 shared_timer_.Stop(); | 788 shared_timer_.Stop(); |
| 789 } | 789 } |
| 790 | 790 |
| 791 void WebKitPlatformSupportImpl::callOnMainThread( | 791 void WebKitPlatformSupportImpl::callOnMainThread( |
| 792 void (*func)(void*), void* context) { | 792 void (*func)(void*), void* context) { |
| 793 main_loop_->PostTask(FROM_HERE, base::Bind(func, context)); | 793 main_loop_->PostTask(FROM_HERE, base::Bind(func, context)); |
| 794 } | 794 } |
| 795 | 795 |
| 796 base::PlatformFile WebKitPlatformSupportImpl::databaseOpenFile( | 796 base::PlatformFile WebKitPlatformSupportImpl::databaseOpenFile( |
| 797 const WebKit::WebString& vfs_file_name, int desired_flags) { | 797 const blink::WebString& vfs_file_name, int desired_flags) { |
| 798 return base::kInvalidPlatformFileValue; | 798 return base::kInvalidPlatformFileValue; |
| 799 } | 799 } |
| 800 | 800 |
| 801 int WebKitPlatformSupportImpl::databaseDeleteFile( | 801 int WebKitPlatformSupportImpl::databaseDeleteFile( |
| 802 const WebKit::WebString& vfs_file_name, bool sync_dir) { | 802 const blink::WebString& vfs_file_name, bool sync_dir) { |
| 803 return -1; | 803 return -1; |
| 804 } | 804 } |
| 805 | 805 |
| 806 long WebKitPlatformSupportImpl::databaseGetFileAttributes( | 806 long WebKitPlatformSupportImpl::databaseGetFileAttributes( |
| 807 const WebKit::WebString& vfs_file_name) { | 807 const blink::WebString& vfs_file_name) { |
| 808 return 0; | 808 return 0; |
| 809 } | 809 } |
| 810 | 810 |
| 811 long long WebKitPlatformSupportImpl::databaseGetFileSize( | 811 long long WebKitPlatformSupportImpl::databaseGetFileSize( |
| 812 const WebKit::WebString& vfs_file_name) { | 812 const blink::WebString& vfs_file_name) { |
| 813 return 0; | 813 return 0; |
| 814 } | 814 } |
| 815 | 815 |
| 816 long long WebKitPlatformSupportImpl::databaseGetSpaceAvailableForOrigin( | 816 long long WebKitPlatformSupportImpl::databaseGetSpaceAvailableForOrigin( |
| 817 const WebKit::WebString& origin_identifier) { | 817 const blink::WebString& origin_identifier) { |
| 818 return 0; | 818 return 0; |
| 819 } | 819 } |
| 820 | 820 |
| 821 WebKit::WebString WebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( | 821 blink::WebString WebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( |
| 822 unsigned key_size_index, | 822 unsigned key_size_index, |
| 823 const WebKit::WebString& challenge, | 823 const blink::WebString& challenge, |
| 824 const WebKit::WebURL& url) { | 824 const blink::WebURL& url) { |
| 825 return WebKit::WebString(""); | 825 return blink::WebString(""); |
| 826 } | 826 } |
| 827 | 827 |
| 828 static scoped_ptr<base::ProcessMetrics> CurrentProcessMetrics() { | 828 static scoped_ptr<base::ProcessMetrics> CurrentProcessMetrics() { |
| 829 using base::ProcessMetrics; | 829 using base::ProcessMetrics; |
| 830 #if defined(OS_MACOSX) | 830 #if defined(OS_MACOSX) |
| 831 return scoped_ptr<ProcessMetrics>( | 831 return scoped_ptr<ProcessMetrics>( |
| 832 // The default port provider is sufficient to get data for the current | 832 // The default port provider is sufficient to get data for the current |
| 833 // process. | 833 // process. |
| 834 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(), | 834 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(), |
| 835 NULL)); | 835 NULL)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 857 | 857 |
| 858 size_t WebKitPlatformSupportImpl::actualMemoryUsageMB() { | 858 size_t WebKitPlatformSupportImpl::actualMemoryUsageMB() { |
| 859 return getMemoryUsageMB(true); | 859 return getMemoryUsageMB(true); |
| 860 } | 860 } |
| 861 | 861 |
| 862 size_t WebKitPlatformSupportImpl::physicalMemoryMB() { | 862 size_t WebKitPlatformSupportImpl::physicalMemoryMB() { |
| 863 return static_cast<size_t>(base::SysInfo::AmountOfPhysicalMemoryMB()); | 863 return static_cast<size_t>(base::SysInfo::AmountOfPhysicalMemoryMB()); |
| 864 } | 864 } |
| 865 | 865 |
| 866 void WebKitPlatformSupportImpl::startHeapProfiling( | 866 void WebKitPlatformSupportImpl::startHeapProfiling( |
| 867 const WebKit::WebString& prefix) { | 867 const blink::WebString& prefix) { |
| 868 // FIXME(morrita): Make this built on windows. | 868 // FIXME(morrita): Make this built on windows. |
| 869 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) | 869 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) |
| 870 HeapProfilerStart(prefix.utf8().data()); | 870 HeapProfilerStart(prefix.utf8().data()); |
| 871 #endif | 871 #endif |
| 872 } | 872 } |
| 873 | 873 |
| 874 void WebKitPlatformSupportImpl::stopHeapProfiling() { | 874 void WebKitPlatformSupportImpl::stopHeapProfiling() { |
| 875 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) | 875 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) |
| 876 HeapProfilerStop(); | 876 HeapProfilerStop(); |
| 877 #endif | 877 #endif |
| 878 } | 878 } |
| 879 | 879 |
| 880 void WebKitPlatformSupportImpl::dumpHeapProfiling( | 880 void WebKitPlatformSupportImpl::dumpHeapProfiling( |
| 881 const WebKit::WebString& reason) { | 881 const blink::WebString& reason) { |
| 882 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) | 882 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) |
| 883 HeapProfilerDump(reason.utf8().data()); | 883 HeapProfilerDump(reason.utf8().data()); |
| 884 #endif | 884 #endif |
| 885 } | 885 } |
| 886 | 886 |
| 887 WebString WebKitPlatformSupportImpl::getHeapProfile() { | 887 WebString WebKitPlatformSupportImpl::getHeapProfile() { |
| 888 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) | 888 #if !defined(NO_TCMALLOC) && defined(USE_TCMALLOC) && !defined(OS_WIN) |
| 889 char* data = GetHeapProfile(); | 889 char* data = GetHeapProfile(); |
| 890 WebString result = WebString::fromUTF8(std::string(data)); | 890 WebString result = WebString::fromUTF8(std::string(data)); |
| 891 free(data); | 891 free(data); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 if (--shared_timer_suspended_ == 0 && | 929 if (--shared_timer_suspended_ == 0 && |
| 930 (!shared_timer_.IsRunning() || | 930 (!shared_timer_.IsRunning() || |
| 931 shared_timer_fire_time_was_set_while_suspended_)) { | 931 shared_timer_fire_time_was_set_while_suspended_)) { |
| 932 shared_timer_fire_time_was_set_while_suspended_ = false; | 932 shared_timer_fire_time_was_set_while_suspended_ = false; |
| 933 setSharedTimerFireInterval( | 933 setSharedTimerFireInterval( |
| 934 shared_timer_fire_time_ - monotonicallyIncreasingTime()); | 934 shared_timer_fire_time_ - monotonicallyIncreasingTime()); |
| 935 } | 935 } |
| 936 } | 936 } |
| 937 | 937 |
| 938 } // namespace webkit_glue | 938 } // namespace webkit_glue |
| OLD | NEW |