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

Side by Side Diff: ppapi/tests/test_utils.h

Issue 2828913003: Replace "nested message loop" with "nested run loop" in comments. (Closed)
Patch Set: rebase Created 3 years, 7 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/tests/test_graphics_2d.cc ('k') | ppapi/tests/test_view.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 (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 #ifndef PPAPI_TESTS_TEST_UTILS_H_ 5 #ifndef PPAPI_TESTS_TEST_UTILS_H_
6 #define PPAPI_TESTS_TEST_UTILS_H_ 6 #define PPAPI_TESTS_TEST_UTILS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ppapi/c/pp_instance.h" 10 #include "ppapi/c/pp_instance.h"
(...skipping 26 matching lines...) Expand all
37 bool ReplacePort(PP_Instance instance, 37 bool ReplacePort(PP_Instance instance,
38 const pp::NetAddress& input_addr, 38 const pp::NetAddress& input_addr,
39 uint16_t port, 39 uint16_t port,
40 pp::NetAddress* output_addr); 40 pp::NetAddress* output_addr);
41 uint16_t GetPort(const pp::NetAddress& addr); 41 uint16_t GetPort(const pp::NetAddress& addr);
42 42
43 // NestedEvent allows you to run a nested MessageLoop and wait for a particular 43 // NestedEvent allows you to run a nested MessageLoop and wait for a particular
44 // event to complete. For example, you can use it to wait for a callback on a 44 // event to complete. For example, you can use it to wait for a callback on a
45 // PPP interface, which will "Signal" the event and make the loop quit. 45 // PPP interface, which will "Signal" the event and make the loop quit.
46 // "Wait()" will return immediately if it has already been signalled. Otherwise, 46 // "Wait()" will return immediately if it has already been signalled. Otherwise,
47 // it will run a nested message loop (using PPB_Testing.RunMessageLoop) and will 47 // it will run a nested run loop (using PPB_Testing.RunMessageLoop) and will
48 // return only after it has been signalled. 48 // return only after it has been signalled.
49 // Example: 49 // Example:
50 // std::string TestFullscreen::TestNormalToFullscreen() { 50 // std::string TestFullscreen::TestNormalToFullscreen() {
51 // pp::Fullscreen screen_mode(instance); 51 // pp::Fullscreen screen_mode(instance);
52 // screen_mode.SetFullscreen(true); 52 // screen_mode.SetFullscreen(true);
53 // SimulateUserGesture(); 53 // SimulateUserGesture();
54 // // Let DidChangeView run in a nested message loop. 54 // // Let DidChangeView run in a nested run loop.
55 // nested_event_.Wait(); 55 // nested_event_.Wait();
56 // Pass(); 56 // Pass();
57 // } 57 // }
58 // 58 //
59 // void TestFullscreen::DidChangeView(const pp::View& view) { 59 // void TestFullscreen::DidChangeView(const pp::View& view) {
60 // nested_event_.Signal(); 60 // nested_event_.Signal();
61 // } 61 // }
62 // 62 //
63 // All methods except Signal and PostSignal must be invoked on the main thread. 63 // All methods except Signal and PostSignal must be invoked on the main thread.
64 // It's OK to signal from a background thread, so you can (for example) Signal() 64 // It's OK to signal from a background thread, so you can (for example) Signal()
65 // from the Audio thread. 65 // from the Audio thread.
66 class NestedEvent { 66 class NestedEvent {
67 public: 67 public:
68 explicit NestedEvent(PP_Instance instance) 68 explicit NestedEvent(PP_Instance instance)
69 : instance_(instance), waiting_(false), signalled_(false) { 69 : instance_(instance), waiting_(false), signalled_(false) {
70 } 70 }
71 // Run a nested message loop and wait until Signal() is called. If Signal() 71 // Run a nested run loop and wait until Signal() is called. If Signal()
72 // has already been called, return immediately without running a nested loop. 72 // has already been called, return immediately without running a nested loop.
73 void Wait(); 73 void Wait();
74 // Signal the NestedEvent. If Wait() has been called, quit the message loop. 74 // Signal the NestedEvent. If Wait() has been called, quit the message loop.
75 // This can be called from any thread. 75 // This can be called from any thread.
76 void Signal(); 76 void Signal();
77 // Signal the NestedEvent in |wait_ms| milliseconds. This can be called from 77 // Signal the NestedEvent in |wait_ms| milliseconds. This can be called from
78 // any thread. 78 // any thread.
79 void PostSignal(int32_t wait_ms); 79 void PostSignal(int32_t wait_ms);
80 80
81 // Reset the NestedEvent so it can be used again. 81 // Reset the NestedEvent so it can be used again.
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 311 }
312 ~ScopedArrayBufferSizeSetter() { 312 ~ScopedArrayBufferSizeSetter() {
313 interface_->SetMinimumArrayBufferSizeForShmem(instance_, 0); 313 interface_->SetMinimumArrayBufferSizeForShmem(instance_, 0);
314 } 314 }
315 private: 315 private:
316 const PPB_Testing_Private* interface_; 316 const PPB_Testing_Private* interface_;
317 PP_Instance instance_; 317 PP_Instance instance_;
318 }; 318 };
319 319
320 #endif // PPAPI_TESTS_TEST_UTILS_H_ 320 #endif // PPAPI_TESTS_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « ppapi/tests/test_graphics_2d.cc ('k') | ppapi/tests/test_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698