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

Side by Side Diff: ppapi/shared_impl/thread_aware_callback_unittest.cc

Issue 1097393007: Update {virtual,override} to follow C++11 style in ppapi. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split off one file into separate review. Created 5 years, 8 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 | « ppapi/shared_impl/test_globals.h ('k') | ppapi/shared_impl/var.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) 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 "ppapi/shared_impl/thread_aware_callback.h" 5 #include "ppapi/shared_impl/thread_aware_callback.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 } 46 }
47 47
48 typedef proxy::PluginProxyTest ThreadAwareCallbackTest; 48 typedef proxy::PluginProxyTest ThreadAwareCallbackTest;
49 49
50 // Test that a callback created on the main thread will run on the main thread, 50 // Test that a callback created on the main thread will run on the main thread,
51 // even when requested from a different thread. 51 // even when requested from a different thread.
52 class ThreadAwareCallbackMultiThreadTest 52 class ThreadAwareCallbackMultiThreadTest
53 : public proxy::PluginProxyMultiThreadTest { 53 : public proxy::PluginProxyMultiThreadTest {
54 public: 54 public:
55 ThreadAwareCallbackMultiThreadTest() : main_thread_callback_called_(false) {} 55 ThreadAwareCallbackMultiThreadTest() : main_thread_callback_called_(false) {}
56 virtual ~ThreadAwareCallbackMultiThreadTest() { 56 ~ThreadAwareCallbackMultiThreadTest() override {
57 CHECK(main_thread_callback_called_); 57 CHECK(main_thread_callback_called_);
58 } 58 }
59 59
60 // proxy::PluginProxyMultiThreadTest implementation. 60 // proxy::PluginProxyMultiThreadTest implementation.
61 virtual void SetUpTestOnMainThread() override { 61 void SetUpTestOnMainThread() override {
62 ProxyAutoLock auto_lock; 62 ProxyAutoLock auto_lock;
63 63
64 main_thread_callback_.reset( 64 main_thread_callback_.reset(
65 ThreadAwareCallback<CallbackFunc>::Create(&MainThreadCallbackBody)); 65 ThreadAwareCallback<CallbackFunc>::Create(&MainThreadCallbackBody));
66 } 66 }
67 67
68 virtual void SetUpTestOnSecondaryThread() override { 68 void SetUpTestOnSecondaryThread() override {
69 { 69 {
70 ProxyAutoLock auto_lock; 70 ProxyAutoLock auto_lock;
71 main_thread_callback_->RunOnTargetThread(this); 71 main_thread_callback_->RunOnTargetThread(this);
72 } 72 }
73 73
74 PostQuitForSecondaryThread(); 74 PostQuitForSecondaryThread();
75 PostQuitForMainThread(); 75 PostQuitForMainThread();
76 } 76 }
77 77
78 private: 78 private:
(...skipping 14 matching lines...) Expand all
93 93
94 scoped_ptr<ThreadAwareCallback<CallbackFunc> > main_thread_callback_; 94 scoped_ptr<ThreadAwareCallback<CallbackFunc> > main_thread_callback_;
95 bool main_thread_callback_called_; 95 bool main_thread_callback_called_;
96 }; 96 };
97 97
98 // Test that when a ThreadAwareCallback instance is destroyed, pending tasks to 98 // Test that when a ThreadAwareCallback instance is destroyed, pending tasks to
99 // run the callback will be ignored. 99 // run the callback will be ignored.
100 class ThreadAwareCallbackAbortTest : public proxy::PluginProxyMultiThreadTest { 100 class ThreadAwareCallbackAbortTest : public proxy::PluginProxyMultiThreadTest {
101 public: 101 public:
102 ThreadAwareCallbackAbortTest() {} 102 ThreadAwareCallbackAbortTest() {}
103 virtual ~ThreadAwareCallbackAbortTest() {} 103 ~ThreadAwareCallbackAbortTest() override {}
104 104
105 // proxy::PluginProxyMultiThreadTest implementation. 105 // proxy::PluginProxyMultiThreadTest implementation.
106 virtual void SetUpTestOnMainThread() override { 106 void SetUpTestOnMainThread() override {
107 ProxyAutoLock auto_lock; 107 ProxyAutoLock auto_lock;
108 108
109 main_thread_callback_.reset( 109 main_thread_callback_.reset(
110 ThreadAwareCallback<CallbackFunc>::Create(&MainThreadCallbackBody)); 110 ThreadAwareCallback<CallbackFunc>::Create(&MainThreadCallbackBody));
111 } 111 }
112 112
113 virtual void SetUpTestOnSecondaryThread() override { 113 void SetUpTestOnSecondaryThread() override {
114 { 114 {
115 ProxyAutoLock auto_lock; 115 ProxyAutoLock auto_lock;
116 main_thread_message_loop_proxy_->PostTask( 116 main_thread_message_loop_proxy_->PostTask(
117 FROM_HERE, 117 FROM_HERE,
118 base::Bind(&ThreadAwareCallbackAbortTest::DeleteCallback, 118 base::Bind(&ThreadAwareCallbackAbortTest::DeleteCallback,
119 base::Unretained(this))); 119 base::Unretained(this)));
120 // |main_thread_callback_| is still valid, even if DeleteCallback() can be 120 // |main_thread_callback_| is still valid, even if DeleteCallback() can be
121 // called before this following statement. That is because |auto_lock| is 121 // called before this following statement. That is because |auto_lock| is
122 // still held by this method, which prevents DeleteCallback() from 122 // still held by this method, which prevents DeleteCallback() from
123 // deleting the callback. 123 // deleting the callback.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 1, &double_arg, &bool_arg, object_arg, object_arg); 190 1, &double_arg, &bool_arg, object_arg, object_arg);
191 191
192 EXPECT_EQ(6, called_num); 192 EXPECT_EQ(6, called_num);
193 } 193 }
194 194
195 TEST_F(ThreadAwareCallbackMultiThreadTest, RunOnTargetThread) { RunTest(); } 195 TEST_F(ThreadAwareCallbackMultiThreadTest, RunOnTargetThread) { RunTest(); }
196 196
197 TEST_F(ThreadAwareCallbackAbortTest, NotRunIfAborted) { RunTest(); } 197 TEST_F(ThreadAwareCallbackAbortTest, NotRunIfAborted) { RunTest(); }
198 198
199 } // namespace ppapi 199 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/test_globals.h ('k') | ppapi/shared_impl/var.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698