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

Side by Side Diff: ppapi/proxy/plugin_globals.h

Issue 10790078: PPAPI: Make PPB_MessageLoop_Dev::GetForMainThread work (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: review comments Created 8 years, 3 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/ppapi_sources.gypi ('k') | ppapi/proxy/plugin_globals.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_PROXY_PLUGIN_GLOBALS_H_ 5 #ifndef PPAPI_PROXY_PLUGIN_GLOBALS_H_
6 #define PPAPI_PROXY_PLUGIN_GLOBALS_H_ 6 #define PPAPI_PROXY_PLUGIN_GLOBALS_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "base/threading/thread_local_storage.h" 11 #include "base/threading/thread_local_storage.h"
12 #include "ppapi/proxy/plugin_resource_tracker.h" 12 #include "ppapi/proxy/plugin_resource_tracker.h"
13 #include "ppapi/proxy/plugin_var_tracker.h" 13 #include "ppapi/proxy/plugin_var_tracker.h"
14 #include "ppapi/proxy/ppapi_proxy_export.h" 14 #include "ppapi/proxy/ppapi_proxy_export.h"
15 #include "ppapi/shared_impl/callback_tracker.h" 15 #include "ppapi/shared_impl/callback_tracker.h"
16 #include "ppapi/shared_impl/ppapi_globals.h" 16 #include "ppapi/shared_impl/ppapi_globals.h"
17 17
18 namespace ppapi { 18 namespace ppapi {
19 namespace proxy { 19 namespace proxy {
20 20
21 class MessageLoopResource;
21 class PluginProxyDelegate; 22 class PluginProxyDelegate;
22 23
23 class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { 24 class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals {
24 public: 25 public:
25 PluginGlobals(); 26 PluginGlobals();
26 PluginGlobals(PpapiGlobals::ForTest); 27 PluginGlobals(PpapiGlobals::ForTest);
27 virtual ~PluginGlobals(); 28 virtual ~PluginGlobals();
28 29
29 // Getter for the global singleton. Generally, you should use 30 // Getter for the global singleton. Generally, you should use
30 // PpapiGlobals::Get() when possible. Use this only when you need some 31 // PpapiGlobals::Get() when possible. Use this only when you need some
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 base::ThreadLocalStorage::Slot* msg_loop_slot() { 80 base::ThreadLocalStorage::Slot* msg_loop_slot() {
80 return msg_loop_slot_.get(); 81 return msg_loop_slot_.get();
81 } 82 }
82 83
83 // Sets the message loop slot, takes ownership of the given heap-alloated 84 // Sets the message loop slot, takes ownership of the given heap-alloated
84 // pointer. 85 // pointer.
85 void set_msg_loop_slot(base::ThreadLocalStorage::Slot* slot) { 86 void set_msg_loop_slot(base::ThreadLocalStorage::Slot* slot) {
86 msg_loop_slot_.reset(slot); 87 msg_loop_slot_.reset(slot);
87 } 88 }
88 89
90 // Return the special Resource that represents the MessageLoop for the main
91 // thread. This Resource is not associated with any instance, and lives as
92 // long as the plugin.
93 MessageLoopResource* loop_for_main_thread();
94
89 // The embedder should call this function when the name of the plugin module 95 // The embedder should call this function when the name of the plugin module
90 // is known. This will be used for error logging. 96 // is known. This will be used for error logging.
91 void set_plugin_name(const std::string& name) { plugin_name_ = name; } 97 void set_plugin_name(const std::string& name) { plugin_name_ = name; }
92 98
93 // The embedder should call this function when the command line is known. 99 // The embedder should call this function when the command line is known.
94 void set_command_line(const std::string& c) { command_line_ = c; } 100 void set_command_line(const std::string& c) { command_line_ = c; }
95 101
96 private: 102 private:
97 // PpapiGlobals overrides. 103 // PpapiGlobals overrides.
98 virtual bool IsPluginGlobals() const OVERRIDE; 104 virtual bool IsPluginGlobals() const OVERRIDE;
99 105
100 static PluginGlobals* plugin_globals_; 106 static PluginGlobals* plugin_globals_;
101 107
102 PluginProxyDelegate* plugin_proxy_delegate_; 108 PluginProxyDelegate* plugin_proxy_delegate_;
103 PluginResourceTracker plugin_resource_tracker_; 109 PluginResourceTracker plugin_resource_tracker_;
104 PluginVarTracker plugin_var_tracker_; 110 PluginVarTracker plugin_var_tracker_;
105 scoped_refptr<CallbackTracker> callback_tracker_; 111 scoped_refptr<CallbackTracker> callback_tracker_;
106 base::Lock proxy_lock_; 112 base::Lock proxy_lock_;
107 113
108 scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_; 114 scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_;
115 // Note that loop_for_main_thread's constructor sets msg_loop_slot_, so it
116 // must be initialized after msg_loop_slot_ (hence the order here).
117 scoped_refptr<MessageLoopResource> loop_for_main_thread_;
109 118
110 // Name of the plugin used for error logging. This will be empty until 119 // Name of the plugin used for error logging. This will be empty until
111 // set_plugin_name is called. 120 // set_plugin_name is called.
112 std::string plugin_name_; 121 std::string plugin_name_;
113 122
114 // Command line for the plugin. This will be empty until set_command_line is 123 // Command line for the plugin. This will be empty until set_command_line is
115 // called. 124 // called.
116 std::string command_line_; 125 std::string command_line_;
117 126
118 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); 127 DISALLOW_COPY_AND_ASSIGN(PluginGlobals);
119 }; 128 };
120 129
121 } // namespace proxy 130 } // namespace proxy
122 } // namespace ppapi 131 } // namespace ppapi
123 132
124 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ 133 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_
OLDNEW
« no previous file with comments | « ppapi/ppapi_sources.gypi ('k') | ppapi/proxy/plugin_globals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698