OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gin/modules/timer.h" | 5 #include "gin/modules/timer.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "gin/handle.h" | 9 #include "gin/handle.h" |
10 #include "gin/object_template_builder.h" | 10 #include "gin/object_template_builder.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 void set_count(int count) { count_ = count; } | 30 void set_count(int count) { count_ = count; } |
31 | 31 |
32 void Quit() { | 32 void Quit() { |
33 base::MessageLoop::current()->QuitNow(); | 33 base::MessageLoop::current()->QuitNow(); |
34 } | 34 } |
35 | 35 |
36 private: | 36 private: |
37 Result() : count_(0) { | 37 Result() : count_(0) { |
38 } | 38 } |
39 | 39 |
40 virtual ~Result() { | 40 ~Result() override {} |
41 } | |
42 | 41 |
43 virtual ObjectTemplateBuilder GetObjectTemplateBuilder( | 42 ObjectTemplateBuilder GetObjectTemplateBuilder( |
44 v8::Isolate* isolate) override { | 43 v8::Isolate* isolate) override { |
45 return Wrappable<Result>::GetObjectTemplateBuilder(isolate) | 44 return Wrappable<Result>::GetObjectTemplateBuilder(isolate) |
46 .SetProperty("count", &Result::count, &Result::set_count) | 45 .SetProperty("count", &Result::count, &Result::set_count) |
47 .SetMethod("quit", &Result::Quit); | 46 .SetMethod("quit", &Result::Quit); |
48 } | 47 } |
49 | 48 |
50 int count_; | 49 int count_; |
51 }; | 50 }; |
52 | 51 |
53 WrapperInfo Result::kWrapperInfo = { gin::kEmbedderNativeGin }; | 52 WrapperInfo Result::kWrapperInfo = { gin::kEmbedderNativeGin }; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // Destroy runner, which should destroy the timer object we created. | 145 // Destroy runner, which should destroy the timer object we created. |
147 helper.QuitSoon(); | 146 helper.QuitSoon(); |
148 helper.runner.reset(NULL); | 147 helper.runner.reset(NULL); |
149 helper.loop.Run(); | 148 helper.loop.Run(); |
150 | 149 |
151 // Timer should not have run because it was deleted. | 150 // Timer should not have run because it was deleted. |
152 EXPECT_EQ(0, helper.result->count()); | 151 EXPECT_EQ(0, helper.result->count()); |
153 } | 152 } |
154 | 153 |
155 } // namespace gin | 154 } // namespace gin |
OLD | NEW |