OLD | NEW |
---|---|
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 plugin_proxy_delegate_ = d; | 73 plugin_proxy_delegate_ = d; |
73 } | 74 } |
74 | 75 |
75 // Returns the TLS slot that holds the message loop TLS. | 76 // Returns the TLS slot that holds the message loop TLS. |
76 // | 77 // |
77 // If we end up needing more TLS storage for more stuff, we should probably | 78 // If we end up needing more TLS storage for more stuff, we should probably |
78 // have a struct in here for the different items. | 79 // have a struct in here for the different items. |
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 } |
83 // Return the special Resource that represents the MessageLoop for the main | |
84 // thread. This Resource is not associated with any instance, and lives as | |
85 // long as the plugin. | |
86 MessageLoopResource* loop_for_main_thread(); | |
bbudge
2012/08/29 22:26:58
This looks out of place between the get and set fo
dmichael (off chromium)
2012/08/30 15:59:10
Good point, done. I also had the body in the wrong
| |
82 | 87 |
83 // Sets the message loop slot, takes ownership of the given heap-alloated | 88 // Sets the message loop slot, takes ownership of the given heap-alloated |
84 // pointer. | 89 // pointer. |
85 void set_msg_loop_slot(base::ThreadLocalStorage::Slot* slot) { | 90 void set_msg_loop_slot(base::ThreadLocalStorage::Slot* slot) { |
86 msg_loop_slot_.reset(slot); | 91 msg_loop_slot_.reset(slot); |
87 } | 92 } |
88 | 93 |
89 // The embedder should call this function when the name of the plugin module | 94 // The embedder should call this function when the name of the plugin module |
90 // is known. This will be used for error logging. | 95 // is known. This will be used for error logging. |
91 void set_plugin_name(const std::string& name) { plugin_name_ = name; } | 96 void set_plugin_name(const std::string& name) { plugin_name_ = name; } |
92 | 97 |
93 // The embedder should call this function when the command line is known. | 98 // The embedder should call this function when the command line is known. |
94 void set_command_line(const std::string& c) { command_line_ = c; } | 99 void set_command_line(const std::string& c) { command_line_ = c; } |
95 | 100 |
96 private: | 101 private: |
97 // PpapiGlobals overrides. | 102 // PpapiGlobals overrides. |
98 virtual bool IsPluginGlobals() const OVERRIDE; | 103 virtual bool IsPluginGlobals() const OVERRIDE; |
99 | 104 |
100 static PluginGlobals* plugin_globals_; | 105 static PluginGlobals* plugin_globals_; |
101 | 106 |
102 PluginProxyDelegate* plugin_proxy_delegate_; | 107 PluginProxyDelegate* plugin_proxy_delegate_; |
103 PluginResourceTracker plugin_resource_tracker_; | 108 PluginResourceTracker plugin_resource_tracker_; |
104 PluginVarTracker plugin_var_tracker_; | 109 PluginVarTracker plugin_var_tracker_; |
105 scoped_refptr<CallbackTracker> callback_tracker_; | 110 scoped_refptr<CallbackTracker> callback_tracker_; |
106 base::Lock proxy_lock_; | 111 base::Lock proxy_lock_; |
107 | 112 |
108 scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_; | 113 scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_; |
114 // Note that loop_for_main_thread's constructor sets msg_loop_slot_, so it | |
115 // must be initialized after msg_loop_slot_ (hence the order here). | |
116 scoped_refptr<MessageLoopResource> loop_for_main_thread_; | |
109 | 117 |
110 // Name of the plugin used for error logging. This will be empty until | 118 // Name of the plugin used for error logging. This will be empty until |
111 // set_plugin_name is called. | 119 // set_plugin_name is called. |
112 std::string plugin_name_; | 120 std::string plugin_name_; |
113 | 121 |
114 // Command line for the plugin. This will be empty until set_command_line is | 122 // Command line for the plugin. This will be empty until set_command_line is |
115 // called. | 123 // called. |
116 std::string command_line_; | 124 std::string command_line_; |
117 | 125 |
118 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); | 126 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); |
119 }; | 127 }; |
120 | 128 |
121 } // namespace proxy | 129 } // namespace proxy |
122 } // namespace ppapi | 130 } // namespace ppapi |
123 | 131 |
124 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 132 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
OLD | NEW |