OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/test/automation/tab_proxy.h" | 5 #include "chrome/test/automation/tab_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 782 |
783 void TabProxy::JavaScriptStressTestControl(int cmd, int param) { | 783 void TabProxy::JavaScriptStressTestControl(int cmd, int param) { |
784 if (!is_valid()) | 784 if (!is_valid()) |
785 return; | 785 return; |
786 | 786 |
787 sender_->Send(new AutomationMsg_JavaScriptStressTestControl( | 787 sender_->Send(new AutomationMsg_JavaScriptStressTestControl( |
788 0, handle_, cmd, param)); | 788 0, handle_, cmd, param)); |
789 } | 789 } |
790 | 790 |
791 void TabProxy::AddObserver(TabProxyDelegate* observer) { | 791 void TabProxy::AddObserver(TabProxyDelegate* observer) { |
792 AutoLock lock(list_lock_); | 792 base::AutoLock lock(list_lock_); |
793 observers_list_.AddObserver(observer); | 793 observers_list_.AddObserver(observer); |
794 } | 794 } |
795 | 795 |
796 void TabProxy::RemoveObserver(TabProxyDelegate* observer) { | 796 void TabProxy::RemoveObserver(TabProxyDelegate* observer) { |
797 AutoLock lock(list_lock_); | 797 base::AutoLock lock(list_lock_); |
798 observers_list_.RemoveObserver(observer); | 798 observers_list_.RemoveObserver(observer); |
799 } | 799 } |
800 | 800 |
801 // Called on Channel background thread, if TabMessages filter is installed. | 801 // Called on Channel background thread, if TabMessages filter is installed. |
802 bool TabProxy::OnMessageReceived(const IPC::Message& message) { | 802 bool TabProxy::OnMessageReceived(const IPC::Message& message) { |
803 AutoLock lock(list_lock_); | 803 base::AutoLock lock(list_lock_); |
804 FOR_EACH_OBSERVER(TabProxyDelegate, observers_list_, | 804 FOR_EACH_OBSERVER(TabProxyDelegate, observers_list_, |
805 OnMessageReceived(this, message)); | 805 OnMessageReceived(this, message)); |
806 return true; | 806 return true; |
807 } | 807 } |
808 | 808 |
809 void TabProxy::OnChannelError() { | 809 void TabProxy::OnChannelError() { |
810 AutoLock lock(list_lock_); | 810 base::AutoLock lock(list_lock_); |
811 FOR_EACH_OBSERVER(TabProxyDelegate, observers_list_, OnChannelError(this)); | 811 FOR_EACH_OBSERVER(TabProxyDelegate, observers_list_, OnChannelError(this)); |
812 } | 812 } |
813 | 813 |
814 TabProxy::~TabProxy() {} | 814 TabProxy::~TabProxy() {} |
815 | 815 |
816 bool TabProxy::ExecuteJavaScriptAndGetJSON(const std::string& script, | 816 bool TabProxy::ExecuteJavaScriptAndGetJSON(const std::string& script, |
817 std::string* json) { | 817 std::string* json) { |
818 if (!is_valid()) | 818 if (!is_valid()) |
819 return false; | 819 return false; |
820 if (!json) { | 820 if (!json) { |
821 NOTREACHED(); | 821 NOTREACHED(); |
822 return false; | 822 return false; |
823 } | 823 } |
824 return sender_->Send(new AutomationMsg_DomOperation(handle_, L"", | 824 return sender_->Send(new AutomationMsg_DomOperation(handle_, L"", |
825 UTF8ToWide(script), | 825 UTF8ToWide(script), |
826 json)); | 826 json)); |
827 } | 827 } |
828 | 828 |
829 void TabProxy::FirstObjectAdded() { | 829 void TabProxy::FirstObjectAdded() { |
830 AddRef(); | 830 AddRef(); |
831 } | 831 } |
832 | 832 |
833 void TabProxy::LastObjectRemoved() { | 833 void TabProxy::LastObjectRemoved() { |
834 Release(); | 834 Release(); |
835 } | 835 } |
OLD | NEW |