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 #ifndef GIN_PUBLIC_V8_PLATFORM_H_ | 5 #ifndef GIN_PUBLIC_V8_PLATFORM_H_ |
6 #define GIN_PUBLIC_V8_PLATFORM_H_ | 6 #define GIN_PUBLIC_V8_PLATFORM_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/memory/scoped_ptr.h" |
11 #include "gin/gin_export.h" | 12 #include "gin/gin_export.h" |
12 #include "v8/include/v8-platform.h" | 13 #include "v8/include/v8-platform.h" |
13 | 14 |
| 15 namespace base { |
| 16 class Thread; |
| 17 } |
| 18 |
14 namespace gin { | 19 namespace gin { |
15 | 20 |
16 // A v8::Platform implementation to use with gin. | 21 // A v8::Platform implementation to use with gin. |
17 class GIN_EXPORT V8Platform : public NON_EXPORTED_BASE(v8::Platform) { | 22 class GIN_EXPORT V8Platform : public NON_EXPORTED_BASE(v8::Platform) { |
18 public: | 23 public: |
19 static V8Platform* Get(); | 24 static V8Platform* Get(); |
20 | 25 |
21 // v8::Platform implementation. | 26 // v8::Platform implementation. |
22 void CallOnBackgroundThread( | 27 void CallOnBackgroundThread( |
23 v8::Task* task, | 28 v8::Task* task, |
24 v8::Platform::ExpectedRuntime expected_runtime) override; | 29 v8::Platform::ExpectedRuntime expected_runtime) override; |
25 void CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) override; | 30 void CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) override; |
26 double MonotonicallyIncreasingTime() override; | 31 double MonotonicallyIncreasingTime() override; |
27 | 32 |
28 private: | 33 private: |
29 friend struct base::DefaultLazyInstanceTraits<V8Platform>; | 34 friend struct base::DefaultLazyInstanceTraits<V8Platform>; |
30 | 35 |
31 V8Platform(); | 36 V8Platform(); |
32 ~V8Platform() override; | 37 ~V8Platform() override; |
| 38 scoped_ptr<base::Thread> background_thread_; |
33 | 39 |
34 DISALLOW_COPY_AND_ASSIGN(V8Platform); | 40 DISALLOW_COPY_AND_ASSIGN(V8Platform); |
35 }; | 41 }; |
36 | 42 |
37 } // namespace gin | 43 } // namespace gin |
38 | 44 |
39 #endif // GIN_PUBLIC_V8_PLATFORM_H_ | 45 #endif // GIN_PUBLIC_V8_PLATFORM_H_ |
OLD | NEW |