Roll src/third_party/skia e66fec2:2bd5d02
[chromium-blink-merge.git] / ppapi / shared_impl / ppb_message_loop_shared.h
blobd28d8be486740c449fd3997883b59746bac29913
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
3 // found in the LICENSE file.
5 #ifndef PPAPI_SHARED_IMPL_PPB_MESSAGE_LOOP_SHARED_H_
6 #define PPAPI_SHARED_IMPL_PPB_MESSAGE_LOOP_SHARED_H_
8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
10 #include "base/location.h"
11 #include "ppapi/c/pp_instance.h"
12 #include "ppapi/shared_impl/ppapi_shared_export.h"
13 #include "ppapi/shared_impl/resource.h"
14 #include "ppapi/thunk/ppb_message_loop_api.h"
16 namespace base {
17 class SingleThreadTaskRunner;
20 namespace tracked_objects {
21 class Location;
24 namespace ppapi {
26 // MessageLoopShared doesn't really do anything interesting. It exists so that
27 // shared code (in particular, TrackedCallback) can keep a pointer to a
28 // MessageLoop resource. In the host side, there is not a concrete class that
29 // implements this. So pointers to MessageLoopShared can only really be valid
30 // on the plugin side.
31 class PPAPI_SHARED_EXPORT MessageLoopShared
32 : public Resource,
33 public thunk::PPB_MessageLoop_API {
34 public:
35 explicit MessageLoopShared(PP_Instance instance);
36 // Construct the one MessageLoopShared for the main thread. This must be
37 // invoked on the main thread.
38 struct ForMainThread {};
39 explicit MessageLoopShared(ForMainThread);
40 virtual ~MessageLoopShared();
42 // Handles posting to the message loop if there is one, or the pending queue
43 // if there isn't.
44 // NOTE: The given closure will be run *WITHOUT* acquiring the Proxy lock.
45 // This only makes sense for user code and completely thread-safe
46 // proxy operations (e.g., MessageLoop::QuitClosure).
47 virtual void PostClosure(const tracked_objects::Location& from_here,
48 const base::Closure& closure,
49 int64 delay_ms) = 0;
51 virtual base::SingleThreadTaskRunner* GetTaskRunner() = 0;
53 // Returns whether this MessageLoop is currently handling a blocking message
54 // from JavaScript. This is used to make it illegal to use blocking callbacks
55 // while the thread is handling a blocking message.
56 virtual bool CurrentlyHandlingBlockingMessage() = 0;
58 DISALLOW_COPY_AND_ASSIGN(MessageLoopShared);
61 } // namespace ppapi
63 #endif // PPAPI_SHARED_IMPL_PPB_MESSAGE_LOOP_SHARED_H_