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

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

Issue 6432001: Implement proxy for FlashMenu and Run/QuitMessageLoop (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle NULL menus more gracefully Created 9 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_utils.h ('k') | webkit/plugins/ppapi/plugin_module.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/tests/test_utils.h" 5 #include "ppapi/tests/test_utils.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "ppapi/c/pp_errors.h" 9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/cpp/module.h" 10 #include "ppapi/cpp/module.h"
11 11
12 const PPB_Testing_Dev* GetTestingInterface() { 12 const PPB_Testing_Dev* GetTestingInterface() {
13 static const PPB_Testing_Dev* g_testing_interface = 13 static const PPB_Testing_Dev* g_testing_interface =
14 reinterpret_cast<PPB_Testing_Dev const*>( 14 reinterpret_cast<PPB_Testing_Dev const*>(
15 pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE)); 15 pp::Module::Get()->GetBrowserInterface(PPB_TESTING_DEV_INTERFACE));
16 return g_testing_interface; 16 return g_testing_interface;
17 } 17 }
18 18
19 std::string ReportError(const char* method, int32_t error) { 19 std::string ReportError(const char* method, int32_t error) {
20 char error_as_string[12]; 20 char error_as_string[12];
21 sprintf(error_as_string, "%d", error); 21 sprintf(error_as_string, "%d", error);
22 std::string result = method + std::string(" failed with error: ") + 22 std::string result = method + std::string(" failed with error: ") +
23 error_as_string; 23 error_as_string;
24 if (error == PP_ERROR_NOSPACE) 24 if (error == PP_ERROR_NOSPACE)
25 result += ". Did you run the test with --unlimited-quota-for-files?"; 25 result += ". Did you run the test with --unlimited-quota-for-files?";
26 return result; 26 return result;
27 } 27 }
28 28
29 TestCompletionCallback::TestCompletionCallback() 29 TestCompletionCallback::TestCompletionCallback(PP_Instance instance)
30 : result_(PP_ERROR_WOULDBLOCK), 30 : result_(PP_ERROR_WOULDBLOCK),
31 post_quit_task_(false), 31 post_quit_task_(false),
32 run_count_(0) { 32 run_count_(0),
33 instance_(instance) {
33 } 34 }
34 35
35 int32_t TestCompletionCallback::WaitForResult() { 36 int32_t TestCompletionCallback::WaitForResult() {
36 result_ = PP_ERROR_WOULDBLOCK; // Reset 37 result_ = PP_ERROR_WOULDBLOCK; // Reset
37 post_quit_task_ = true; 38 post_quit_task_ = true;
38 GetTestingInterface()->RunMessageLoop(); 39 GetTestingInterface()->RunMessageLoop(instance_);
39 return result_; 40 return result_;
40 } 41 }
41 42
42 TestCompletionCallback::operator pp::CompletionCallback() const { 43 TestCompletionCallback::operator pp::CompletionCallback() const {
43 return pp::CompletionCallback(&TestCompletionCallback::Handler, 44 return pp::CompletionCallback(&TestCompletionCallback::Handler,
44 const_cast<TestCompletionCallback*>(this)); 45 const_cast<TestCompletionCallback*>(this));
45 } 46 }
46 47
47 // static 48 // static
48 void TestCompletionCallback::Handler(void* user_data, int32_t result) { 49 void TestCompletionCallback::Handler(void* user_data, int32_t result) {
49 TestCompletionCallback* callback = 50 TestCompletionCallback* callback =
50 static_cast<TestCompletionCallback*>(user_data); 51 static_cast<TestCompletionCallback*>(user_data);
51 callback->result_ = result; 52 callback->result_ = result;
52 callback->run_count_++; 53 callback->run_count_++;
53 if (callback->post_quit_task_) { 54 if (callback->post_quit_task_) {
54 callback->post_quit_task_ = false; 55 callback->post_quit_task_ = false;
55 GetTestingInterface()->QuitMessageLoop(); 56 GetTestingInterface()->QuitMessageLoop(callback->instance_);
56 } 57 }
57 } 58 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_utils.h ('k') | webkit/plugins/ppapi/plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698