| 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 <string> |
| 9 |
| 8 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 11 #include "base/threading/thread_local_storage.h" | 13 #include "base/threading/thread_local_storage.h" |
| 12 #include "ppapi/proxy/plugin_resource_tracker.h" | 14 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 13 #include "ppapi/proxy/plugin_var_tracker.h" | 15 #include "ppapi/proxy/plugin_var_tracker.h" |
| 14 #include "ppapi/proxy/ppapi_proxy_export.h" | 16 #include "ppapi/proxy/ppapi_proxy_export.h" |
| 15 #include "ppapi/shared_impl/callback_tracker.h" | 17 #include "ppapi/shared_impl/callback_tracker.h" |
| 16 #include "ppapi/shared_impl/ppapi_globals.h" | 18 #include "ppapi/shared_impl/ppapi_globals.h" |
| 17 | 19 |
| 20 namespace IPC { |
| 21 class Sender; |
| 22 } |
| 23 |
| 18 namespace ppapi { | 24 namespace ppapi { |
| 19 namespace proxy { | 25 namespace proxy { |
| 20 | 26 |
| 21 class MessageLoopResource; | 27 class MessageLoopResource; |
| 22 class PluginProxyDelegate; | 28 class PluginProxyDelegate; |
| 23 | 29 |
| 24 class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { | 30 class PPAPI_PROXY_EXPORT PluginGlobals : public PpapiGlobals { |
| 25 public: | 31 public: |
| 26 PluginGlobals(); | 32 PluginGlobals(); |
| 27 PluginGlobals(PpapiGlobals::ForTest); | 33 PluginGlobals(PpapiGlobals::ForTest); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 51 virtual void LogWithSource(PP_Instance instance, | 57 virtual void LogWithSource(PP_Instance instance, |
| 52 PP_LogLevel_Dev level, | 58 PP_LogLevel_Dev level, |
| 53 const std::string& source, | 59 const std::string& source, |
| 54 const std::string& value) OVERRIDE; | 60 const std::string& value) OVERRIDE; |
| 55 virtual void BroadcastLogWithSource(PP_Module module, | 61 virtual void BroadcastLogWithSource(PP_Module module, |
| 56 PP_LogLevel_Dev level, | 62 PP_LogLevel_Dev level, |
| 57 const std::string& source, | 63 const std::string& source, |
| 58 const std::string& value) OVERRIDE; | 64 const std::string& value) OVERRIDE; |
| 59 virtual MessageLoopShared* GetCurrentMessageLoop() OVERRIDE; | 65 virtual MessageLoopShared* GetCurrentMessageLoop() OVERRIDE; |
| 60 | 66 |
| 67 // Returns the channel for sending to the browser. |
| 68 IPC::Sender* GetBrowserSender(); |
| 69 |
| 70 // Returns the language code of the current UI language. |
| 71 std::string GetUILanguage(); |
| 72 |
| 73 // Sets the active url which is reported by breakpad. |
| 74 void SetActiveURL(const std::string& url); |
| 75 |
| 61 // Getters for the plugin-specific versions. | 76 // Getters for the plugin-specific versions. |
| 62 PluginResourceTracker* plugin_resource_tracker() { | 77 PluginResourceTracker* plugin_resource_tracker() { |
| 63 return &plugin_resource_tracker_; | 78 return &plugin_resource_tracker_; |
| 64 } | 79 } |
| 65 PluginVarTracker* plugin_var_tracker() { | 80 PluginVarTracker* plugin_var_tracker() { |
| 66 return &plugin_var_tracker_; | 81 return &plugin_var_tracker_; |
| 67 } | 82 } |
| 68 | 83 |
| 69 // The embedder should call set_proxy_delegate during startup. | 84 // The embedder should call set_proxy_delegate during startup. |
| 70 PluginProxyDelegate* plugin_proxy_delegate() { | |
| 71 return plugin_proxy_delegate_; | |
| 72 } | |
| 73 void set_plugin_proxy_delegate(PluginProxyDelegate* d) { | 85 void set_plugin_proxy_delegate(PluginProxyDelegate* d) { |
| 74 plugin_proxy_delegate_ = d; | 86 plugin_proxy_delegate_ = d; |
| 75 } | 87 } |
| 76 | 88 |
| 77 // Returns the TLS slot that holds the message loop TLS. | 89 // Returns the TLS slot that holds the message loop TLS. |
| 78 // | 90 // |
| 79 // If we end up needing more TLS storage for more stuff, we should probably | 91 // If we end up needing more TLS storage for more stuff, we should probably |
| 80 // have a struct in here for the different items. | 92 // have a struct in here for the different items. |
| 81 base::ThreadLocalStorage::Slot* msg_loop_slot() { | 93 base::ThreadLocalStorage::Slot* msg_loop_slot() { |
| 82 return msg_loop_slot_.get(); | 94 return msg_loop_slot_.get(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 94 MessageLoopResource* loop_for_main_thread(); | 106 MessageLoopResource* loop_for_main_thread(); |
| 95 | 107 |
| 96 // The embedder should call this function when the name of the plugin module | 108 // The embedder should call this function when the name of the plugin module |
| 97 // is known. This will be used for error logging. | 109 // is known. This will be used for error logging. |
| 98 void set_plugin_name(const std::string& name) { plugin_name_ = name; } | 110 void set_plugin_name(const std::string& name) { plugin_name_ = name; } |
| 99 | 111 |
| 100 // The embedder should call this function when the command line is known. | 112 // The embedder should call this function when the command line is known. |
| 101 void set_command_line(const std::string& c) { command_line_ = c; } | 113 void set_command_line(const std::string& c) { command_line_ = c; } |
| 102 | 114 |
| 103 private: | 115 private: |
| 116 class BrowserSender; |
| 117 |
| 104 // PpapiGlobals overrides. | 118 // PpapiGlobals overrides. |
| 105 virtual bool IsPluginGlobals() const OVERRIDE; | 119 virtual bool IsPluginGlobals() const OVERRIDE; |
| 106 | 120 |
| 107 static PluginGlobals* plugin_globals_; | 121 static PluginGlobals* plugin_globals_; |
| 108 | 122 |
| 109 PluginProxyDelegate* plugin_proxy_delegate_; | 123 PluginProxyDelegate* plugin_proxy_delegate_; |
| 110 PluginResourceTracker plugin_resource_tracker_; | 124 PluginResourceTracker plugin_resource_tracker_; |
| 111 PluginVarTracker plugin_var_tracker_; | 125 PluginVarTracker plugin_var_tracker_; |
| 112 scoped_refptr<CallbackTracker> callback_tracker_; | 126 scoped_refptr<CallbackTracker> callback_tracker_; |
| 113 base::Lock proxy_lock_; | 127 base::Lock proxy_lock_; |
| 114 | 128 |
| 115 scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_; | 129 scoped_ptr<base::ThreadLocalStorage::Slot> msg_loop_slot_; |
| 116 // Note that loop_for_main_thread's constructor sets msg_loop_slot_, so it | 130 // Note that loop_for_main_thread's constructor sets msg_loop_slot_, so it |
| 117 // must be initialized after msg_loop_slot_ (hence the order here). | 131 // must be initialized after msg_loop_slot_ (hence the order here). |
| 118 scoped_refptr<MessageLoopResource> loop_for_main_thread_; | 132 scoped_refptr<MessageLoopResource> loop_for_main_thread_; |
| 119 | 133 |
| 120 // Name of the plugin used for error logging. This will be empty until | 134 // Name of the plugin used for error logging. This will be empty until |
| 121 // set_plugin_name is called. | 135 // set_plugin_name is called. |
| 122 std::string plugin_name_; | 136 std::string plugin_name_; |
| 123 | 137 |
| 124 // Command line for the plugin. This will be empty until set_command_line is | 138 // Command line for the plugin. This will be empty until set_command_line is |
| 125 // called. | 139 // called. |
| 126 std::string command_line_; | 140 std::string command_line_; |
| 127 | 141 |
| 142 scoped_ptr<BrowserSender> browser_sender_; |
| 143 |
| 128 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); | 144 DISALLOW_COPY_AND_ASSIGN(PluginGlobals); |
| 129 }; | 145 }; |
| 130 | 146 |
| 131 } // namespace proxy | 147 } // namespace proxy |
| 132 } // namespace ppapi | 148 } // namespace ppapi |
| 133 | 149 |
| 134 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ | 150 #endif // PPAPI_PROXY_PLUGIN_GLOBALS_H_ |
| OLD | NEW |