| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_FRAME_CHROME_FRAME_AUTOMATION_H_ | 5 #ifndef CHROME_FRAME_CHROME_FRAME_AUTOMATION_H_ |
| 6 #define CHROME_FRAME_CHROME_FRAME_AUTOMATION_H_ | 6 #define CHROME_FRAME_CHROME_FRAME_AUTOMATION_H_ |
| 7 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlwin.h> | 9 #include <atlwin.h> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_handle.h" | 15 #include "base/memory/scoped_handle.h" |
| 16 #include "base/stack_container.h" | 16 #include "base/stack_container.h" |
| 17 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 18 #include "base/task.h" | 18 #include "base/task.h" |
| 19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
| 20 #include "base/timer.h" | 20 #include "base/timer.h" |
| 21 #include "chrome/test/automation/automation_proxy.h" | 21 #include "chrome/test/automation/automation_proxy.h" |
| 22 #include "chrome/test/automation/tab_proxy.h" | 22 #include "chrome/test/automation/tab_proxy.h" |
| 23 #include "chrome_frame/chrome_frame_delegate.h" | 23 #include "chrome_frame/chrome_frame_delegate.h" |
| 24 #include "chrome_frame/chrome_frame_histograms.h" | |
| 25 #include "chrome_frame/plugin_url_request.h" | 24 #include "chrome_frame/plugin_url_request.h" |
| 26 #include "chrome_frame/sync_msg_reply_dispatcher.h" | 25 #include "chrome_frame/sync_msg_reply_dispatcher.h" |
| 27 #include "content/common/page_zoom.h" | 26 #include "content/common/page_zoom.h" |
| 28 | 27 |
| 29 // By a convoluated route, this timeout also winds up being the sync automation | 28 // By a convoluated route, this timeout also winds up being the sync automation |
| 30 // message timeout. See the ChromeFrameAutomationProxyImpl ctor and the | 29 // message timeout. See the ChromeFrameAutomationProxyImpl ctor and the |
| 31 // AutomationProxy ctor for details. | 30 // AutomationProxy ctor for details. |
| 32 const unsigned long kCommandExecutionTimeout = 60000; // NOLINT, 60 seconds | 31 const unsigned long kCommandExecutionTimeout = 60000; // NOLINT, 60 seconds |
| 33 | 32 |
| 34 class ProxyFactory; | 33 class ProxyFactory; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 public: | 223 public: |
| 225 AutomationProxyCacheEntry(ChromeFrameLaunchParams* params, | 224 AutomationProxyCacheEntry(ChromeFrameLaunchParams* params, |
| 226 LaunchDelegate* delegate); | 225 LaunchDelegate* delegate); |
| 227 | 226 |
| 228 ~AutomationProxyCacheEntry(); | 227 ~AutomationProxyCacheEntry(); |
| 229 | 228 |
| 230 void AddDelegate(LaunchDelegate* delegate); | 229 void AddDelegate(LaunchDelegate* delegate); |
| 231 void RemoveDelegate(LaunchDelegate* delegate, base::WaitableEvent* done, | 230 void RemoveDelegate(LaunchDelegate* delegate, base::WaitableEvent* done, |
| 232 bool* was_last_delegate); | 231 bool* was_last_delegate); |
| 233 | 232 |
| 234 void StartSendUmaInterval(ChromeFrameHistogramSnapshots* snapshots, | |
| 235 int send_interval); | |
| 236 | |
| 237 DWORD WaitForThread(DWORD timeout) { // NOLINT | 233 DWORD WaitForThread(DWORD timeout) { // NOLINT |
| 238 DCHECK(thread_.get()); | 234 DCHECK(thread_.get()); |
| 239 return ::WaitForSingleObject(thread_->thread_handle(), timeout); | 235 return ::WaitForSingleObject(thread_->thread_handle(), timeout); |
| 240 } | 236 } |
| 241 | 237 |
| 242 bool IsSameProfile(const std::wstring& name) const { | 238 bool IsSameProfile(const std::wstring& name) const { |
| 243 return lstrcmpiW(name.c_str(), profile_name.c_str()) == 0; | 239 return lstrcmpiW(name.c_str(), profile_name.c_str()) == 0; |
| 244 } | 240 } |
| 245 | 241 |
| 246 base::Thread* thread() const { | 242 base::Thread* thread() const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 259 DCHECK(IsSameThread(base::PlatformThread::CurrentId())); | 255 DCHECK(IsSameThread(base::PlatformThread::CurrentId())); |
| 260 return proxy_.get(); | 256 return proxy_.get(); |
| 261 } | 257 } |
| 262 | 258 |
| 263 // Called by the proxy when the automation server has unexpectedly gone away. | 259 // Called by the proxy when the automation server has unexpectedly gone away. |
| 264 void OnChannelError(); | 260 void OnChannelError(); |
| 265 | 261 |
| 266 protected: | 262 protected: |
| 267 void CreateProxy(ChromeFrameLaunchParams* params, | 263 void CreateProxy(ChromeFrameLaunchParams* params, |
| 268 LaunchDelegate* delegate); | 264 LaunchDelegate* delegate); |
| 269 void SendUMAData(); | |
| 270 | 265 |
| 271 protected: | 266 protected: |
| 272 std::wstring profile_name; | 267 std::wstring profile_name; |
| 273 scoped_ptr<base::Thread> thread_; | 268 scoped_ptr<base::Thread> thread_; |
| 274 scoped_ptr<ChromeFrameAutomationProxyImpl> proxy_; | 269 scoped_ptr<ChromeFrameAutomationProxyImpl> proxy_; |
| 275 AutomationLaunchResult launch_result_; | 270 AutomationLaunchResult launch_result_; |
| 276 typedef std::vector<LaunchDelegate*> LaunchDelegates; | 271 typedef std::vector<LaunchDelegate*> LaunchDelegates; |
| 277 LaunchDelegates launch_delegates_; | 272 LaunchDelegates launch_delegates_; |
| 278 // Used for UMA histogram logging to measure the time for the chrome | 273 // Used for UMA histogram logging to measure the time for the chrome |
| 279 // automation server to start; | 274 // automation server to start; |
| 280 base::TimeTicks automation_server_launch_start_time_; | 275 base::TimeTicks automation_server_launch_start_time_; |
| 281 ChromeFrameHistogramSnapshots* snapshots_; | |
| 282 int uma_send_interval_; | |
| 283 }; | 276 }; |
| 284 | 277 |
| 285 // We must create and destroy automation proxy in a thread with a message loop. | 278 // We must create and destroy automation proxy in a thread with a message loop. |
| 286 // Hence thread cannot be a member of the proxy. | 279 // Hence thread cannot be a member of the proxy. |
| 287 class ProxyFactory { | 280 class ProxyFactory { |
| 288 public: | 281 public: |
| 289 ProxyFactory(); | 282 ProxyFactory(); |
| 290 virtual ~ProxyFactory(); | 283 virtual ~ProxyFactory(); |
| 291 | 284 |
| 292 // Fetches or creates a new automation server instance. | 285 // Fetches or creates a new automation server instance. |
| 293 // delegate may be NULL. If non-null, a pointer to the delegate will | 286 // delegate may be NULL. If non-null, a pointer to the delegate will |
| 294 // be stored for the lifetime of the automation process or until | 287 // be stored for the lifetime of the automation process or until |
| 295 // ReleaseAutomationServer is called. | 288 // ReleaseAutomationServer is called. |
| 296 virtual void GetAutomationServer(LaunchDelegate* delegate, | 289 virtual void GetAutomationServer(LaunchDelegate* delegate, |
| 297 ChromeFrameLaunchParams* params, | 290 ChromeFrameLaunchParams* params, |
| 298 void** automation_server_id); | 291 void** automation_server_id); |
| 299 virtual bool ReleaseAutomationServer(void* server_id, | 292 virtual bool ReleaseAutomationServer(void* server_id, |
| 300 LaunchDelegate* delegate); | 293 LaunchDelegate* delegate); |
| 301 | 294 |
| 302 private: | 295 private: |
| 303 typedef StackVector<scoped_refptr<AutomationProxyCacheEntry>, 4> Vector; | 296 typedef StackVector<scoped_refptr<AutomationProxyCacheEntry>, 4> Vector; |
| 304 Vector proxies_; | 297 Vector proxies_; |
| 305 // Lock if we are going to call GetAutomationServer from more than one thread. | 298 // Lock if we are going to call GetAutomationServer from more than one thread. |
| 306 base::Lock lock_; | 299 base::Lock lock_; |
| 307 | |
| 308 // Gathers histograms to be sent to Chrome. | |
| 309 ChromeFrameHistogramSnapshots chrome_frame_histograms_; | |
| 310 | |
| 311 // Interval for sending UMA data | |
| 312 int uma_send_interval_; | |
| 313 }; | 300 }; |
| 314 | 301 |
| 315 // Handles all automation requests initiated from the chrome frame objects. | 302 // Handles all automation requests initiated from the chrome frame objects. |
| 316 // These include the chrome tab/chrome frame activex/chrome frame npapi | 303 // These include the chrome tab/chrome frame activex plugin objects. |
| 317 // plugin objects. | |
| 318 class ChromeFrameAutomationClient | 304 class ChromeFrameAutomationClient |
| 319 : public CWindowImpl<ChromeFrameAutomationClient>, | 305 : public CWindowImpl<ChromeFrameAutomationClient>, |
| 320 public TaskMarshallerThroughWindowsMessages<ChromeFrameAutomationClient>, | 306 public TaskMarshallerThroughWindowsMessages<ChromeFrameAutomationClient>, |
| 321 public base::RefCountedThreadSafe<ChromeFrameAutomationClient>, | 307 public base::RefCountedThreadSafe<ChromeFrameAutomationClient>, |
| 322 public PluginUrlRequestDelegate, | 308 public PluginUrlRequestDelegate, |
| 323 public TabProxy::TabProxyDelegate, | 309 public TabProxy::TabProxyDelegate, |
| 324 public LaunchDelegate { | 310 public LaunchDelegate { |
| 325 public: | 311 public: |
| 326 ChromeFrameAutomationClient(); | 312 ChromeFrameAutomationClient(); |
| 327 ~ChromeFrameAutomationClient(); | 313 ~ChromeFrameAutomationClient(); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 // set to true if the host needs to get notified of all top level navigations | 524 // set to true if the host needs to get notified of all top level navigations |
| 539 // in this page. This typically applies to hosts which would render the new | 525 // in this page. This typically applies to hosts which would render the new |
| 540 // page without chrome frame. Defaults to false. | 526 // page without chrome frame. Defaults to false. |
| 541 bool route_all_top_level_navigations_; | 527 bool route_all_top_level_navigations_; |
| 542 | 528 |
| 543 friend class BeginNavigateContext; | 529 friend class BeginNavigateContext; |
| 544 friend class CreateExternalTabContext; | 530 friend class CreateExternalTabContext; |
| 545 }; | 531 }; |
| 546 | 532 |
| 547 #endif // CHROME_FRAME_CHROME_FRAME_AUTOMATION_H_ | 533 #endif // CHROME_FRAME_CHROME_FRAME_AUTOMATION_H_ |
| OLD | NEW |