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

Unified Diff: ppapi/cpp/message_loop.cc

Issue 11364188: PPAPI: Take PPB_MessageLoop out of Dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/message_loop.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/message_loop.cc
diff --git a/ppapi/cpp/message_loop.cc b/ppapi/cpp/message_loop.cc
new file mode 100644
index 0000000000000000000000000000000000000000..df3800737ddce4b53b5dfdb317315541fb3eb02f
--- /dev/null
+++ b/ppapi/cpp/message_loop.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/message_loop.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/ppb_message_loop.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_MessageLoop>() {
+ return PPB_MESSAGELOOP_INTERFACE_1_0;
+}
+
+} // namespace
+
+MessageLoop::MessageLoop() : Resource() {
+}
+
+MessageLoop::MessageLoop(const InstanceHandle& instance) : Resource() {
+ if (has_interface<PPB_MessageLoop>()) {
+ PassRefFromConstructor(get_interface<PPB_MessageLoop>()->Create(
+ instance.pp_instance()));
+ }
+}
+
+MessageLoop::MessageLoop(const MessageLoop& other)
+ : Resource(other) {
+}
+
+MessageLoop::MessageLoop(PP_Resource pp_message_loop)
+ : Resource(pp_message_loop) {
+}
+
+// static
+MessageLoop MessageLoop::GetForMainThread() {
+ if (!has_interface<PPB_MessageLoop>())
+ return MessageLoop();
+ return MessageLoop(
+ get_interface<PPB_MessageLoop>()->GetForMainThread());
+}
+
+// static
+MessageLoop MessageLoop::GetCurrent() {
+ if (!has_interface<PPB_MessageLoop>())
+ return MessageLoop();
+ return MessageLoop(
+ get_interface<PPB_MessageLoop>()->GetCurrent());
+}
+
+int32_t MessageLoop::AttachToCurrentThread() {
+ if (!has_interface<PPB_MessageLoop>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_MessageLoop>()->AttachToCurrentThread(
+ pp_resource());
+}
+
+int32_t MessageLoop::Run() {
+ if (!has_interface<PPB_MessageLoop>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_MessageLoop>()->Run(pp_resource());
+}
+
+int32_t MessageLoop::PostWork(const CompletionCallback& callback,
+ int64_t delay_ms) {
+ if (!has_interface<PPB_MessageLoop>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_MessageLoop>()->PostWork(
+ pp_resource(),
+ callback.pp_completion_callback(),
+ delay_ms);
+}
+
+int32_t MessageLoop::PostQuit(bool should_destroy) {
+ if (!has_interface<PPB_MessageLoop>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_MessageLoop>()->PostQuit(
+ pp_resource(), PP_FromBool(should_destroy));
+}
+
+} // namespace pp
« no previous file with comments | « ppapi/cpp/message_loop.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698