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

Side by Side Diff: sky/viewer/platform/platform_impl.h

Issue 886263002: Move SharedTimer implementation into sky/engine (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: style Created 5 years, 10 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
« no previous file with comments | « sky/engine/testing/platform/platform_impl.cc ('k') | sky/viewer/platform/platform_impl.cc » ('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 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 #ifndef SKY_VIEWER_PLATFORM_PLATFORM_IMPL_H_ 5 #ifndef SKY_VIEWER_PLATFORM_PLATFORM_IMPL_H_
6 #define SKY_VIEWER_PLATFORM_PLATFORM_IMPL_H_ 6 #define SKY_VIEWER_PLATFORM_PLATFORM_IMPL_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/threading/thread_local_storage.h" 10 #include "base/threading/thread_local_storage.h"
11 #include "base/timer/timer.h" 11 #include "base/timer/timer.h"
12 #include "mojo/services/network/public/interfaces/network_service.mojom.h" 12 #include "mojo/services/network/public/interfaces/network_service.mojom.h"
13 #include "sky/engine/public/platform/Platform.h" 13 #include "sky/engine/public/platform/Platform.h"
14 14
15 namespace mojo { 15 namespace mojo {
16 class ApplicationImpl; 16 class ApplicationImpl;
17 } 17 }
18 18
19 namespace sky { 19 namespace sky {
20 20
21 class PlatformImpl : public blink::Platform { 21 class PlatformImpl : public blink::Platform {
22 public: 22 public:
23 explicit PlatformImpl(mojo::ApplicationImpl* app); 23 explicit PlatformImpl(mojo::ApplicationImpl* app);
24 virtual ~PlatformImpl(); 24 virtual ~PlatformImpl();
25 25
26 // blink::Platform methods: 26 // blink::Platform methods:
27 virtual blink::WebString defaultLocale(); 27 virtual blink::WebString defaultLocale();
28 virtual void setSharedTimerFiredFunction(void (*func)());
29 virtual void setSharedTimerFireInterval(double interval_seconds);
30 virtual void stopSharedTimer();
31 virtual base::SingleThreadTaskRunner* mainThreadTaskRunner(); 28 virtual base::SingleThreadTaskRunner* mainThreadTaskRunner();
32 virtual mojo::NetworkService* networkService(); 29 virtual mojo::NetworkService* networkService();
33 virtual blink::WebURLLoader* createURLLoader(); 30 virtual blink::WebURLLoader* createURLLoader();
34 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const; 31 virtual blink::WebURLError cancelledError(const blink::WebURL& url) const;
35 32
36 private: 33 private:
37 void SuspendSharedTimer();
38 void ResumeSharedTimer();
39
40 void DoTimeout() {
41 if (shared_timer_func_ && !shared_timer_suspended_)
42 shared_timer_func_();
43 }
44
45 mojo::NetworkServicePtr network_service_; 34 mojo::NetworkServicePtr network_service_;
46 base::MessageLoop* main_loop_; 35 base::MessageLoop* main_loop_;
47 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; 36 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
48 base::OneShotTimer<PlatformImpl> shared_timer_;
49 void (*shared_timer_func_)();
50 double shared_timer_fire_time_;
51 bool shared_timer_fire_time_was_set_while_suspended_;
52 int shared_timer_suspended_; // counter
53 37
54 DISALLOW_COPY_AND_ASSIGN(PlatformImpl); 38 DISALLOW_COPY_AND_ASSIGN(PlatformImpl);
55 }; 39 };
56 40
57 } // namespace sky 41 } // namespace sky
58 42
59 #endif // SKY_VIEWER_PLATFORM_PLATFORM_IMPL_H_ 43 #endif // SKY_VIEWER_PLATFORM_PLATFORM_IMPL_H_
OLDNEW
« no previous file with comments | « sky/engine/testing/platform/platform_impl.cc ('k') | sky/viewer/platform/platform_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698