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

Side by Side Diff: ppapi/proxy/ppb_core_proxy.cc

Issue 7344009: Move the time conversion code to the PPAPI shared_impl directory and use it in (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/ppapi_shared.gypi ('k') | ppapi/shared_impl/time_conversion.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ppapi/proxy/ppb_core_proxy.h" 5 #include "ppapi/proxy/ppb_core_proxy.h"
6 6
7 #include <stdlib.h> // For malloc 7 #include <stdlib.h> // For malloc
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_resource.h" 14 #include "ppapi/c/pp_resource.h"
15 #include "ppapi/c/ppb_core.h" 15 #include "ppapi/c/ppb_core.h"
16 #include "ppapi/proxy/plugin_dispatcher.h" 16 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/plugin_resource_tracker.h" 17 #include "ppapi/proxy/plugin_resource_tracker.h"
18 #include "ppapi/proxy/ppapi_messages.h" 18 #include "ppapi/proxy/ppapi_messages.h"
19 #include "ppapi/shared_impl/time_conversion.h"
20
21 using ppapi::TimeToPPTime;
22 using ppapi::TimeTicksToPPTimeTicks;
19 23
20 namespace pp { 24 namespace pp {
21 namespace proxy { 25 namespace proxy {
22 26
23 namespace { 27 namespace {
24 28
25 base::MessageLoopProxy* GetMainThreadMessageLoop() { 29 base::MessageLoopProxy* GetMainThreadMessageLoop() {
26 static scoped_refptr<base::MessageLoopProxy> proxy( 30 static scoped_refptr<base::MessageLoopProxy> proxy(
27 base::MessageLoopProxy::CreateForCurrentThread()); 31 base::MessageLoopProxy::CreateForCurrentThread());
28 return proxy.get(); 32 return proxy.get();
29 } 33 }
30 34
31 void AddRefResource(PP_Resource resource) { 35 void AddRefResource(PP_Resource resource) {
32 PluginResourceTracker::GetInstance()->AddRefResource(resource); 36 PluginResourceTracker::GetInstance()->AddRefResource(resource);
33 } 37 }
34 38
35 void ReleaseResource(PP_Resource resource) { 39 void ReleaseResource(PP_Resource resource) {
36 PluginResourceTracker::GetInstance()->ReleaseResource(resource); 40 PluginResourceTracker::GetInstance()->ReleaseResource(resource);
37 } 41 }
38 42
39 void* MemAlloc(uint32_t num_bytes) { 43 void* MemAlloc(uint32_t num_bytes) {
40 return malloc(num_bytes); 44 return malloc(num_bytes);
41 } 45 }
42 46
43 void MemFree(void* ptr) { 47 void MemFree(void* ptr) {
44 free(ptr); 48 free(ptr);
45 } 49 }
46 50
47 double GetTime() { 51 double GetTime() {
48 return base::Time::Now().ToDoubleT(); 52 return TimeToPPTime(base::Time::Now());
49 } 53 }
50 54
51 double GetTimeTicks() { 55 double GetTimeTicks() {
52 // TODO(brettw) http://code.google.com/p/chromium/issues/detail?id=57448 56 return TimeTicksToPPTimeTicks(base::TimeTicks::Now());
53 // This should be a tick timer rather than wall clock time, but needs to
54 // match message times, which also currently use wall clock time.
55 return GetTime();
56 } 57 }
57 58
58 void CallOnMainThread(int delay_in_ms, 59 void CallOnMainThread(int delay_in_ms,
59 PP_CompletionCallback callback, 60 PP_CompletionCallback callback,
60 int32_t result) { 61 int32_t result) {
61 GetMainThreadMessageLoop()->PostDelayedTask( 62 GetMainThreadMessageLoop()->PostDelayedTask(
62 FROM_HERE, 63 FROM_HERE,
63 NewRunnableFunction(callback.func, callback.user_data, result), 64 NewRunnableFunction(callback.func, callback.user_data, result),
64 delay_in_ms); 65 delay_in_ms);
65 } 66 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 void PPB_Core_Proxy::OnMsgAddRefResource(HostResource resource) { 123 void PPB_Core_Proxy::OnMsgAddRefResource(HostResource resource) {
123 ppb_core_target()->AddRefResource(resource.host_resource()); 124 ppb_core_target()->AddRefResource(resource.host_resource());
124 } 125 }
125 126
126 void PPB_Core_Proxy::OnMsgReleaseResource(HostResource resource) { 127 void PPB_Core_Proxy::OnMsgReleaseResource(HostResource resource) {
127 ppb_core_target()->ReleaseResource(resource.host_resource()); 128 ppb_core_target()->ReleaseResource(resource.host_resource());
128 } 129 }
129 130
130 } // namespace proxy 131 } // namespace proxy
131 } // namespace pp 132 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/ppapi_shared.gypi ('k') | ppapi/shared_impl/time_conversion.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698