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

Unified Diff: chrome/test/automation/tab_proxy.cc

Issue 113722: Make automation proxy objects to ref_counted. That allows to process async no... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/automation/tab_proxy.h ('k') | chrome/test/automation/window_proxy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/automation/tab_proxy.cc
===================================================================
--- chrome/test/automation/tab_proxy.cc (revision 17078)
+++ chrome/test/automation/tab_proxy.cc (working copy)
@@ -337,19 +337,31 @@
0, handle_, count));
}
-ConstrainedWindowProxy* TabProxy::GetConstrainedWindow(
+scoped_refptr<ConstrainedWindowProxy> TabProxy::GetConstrainedWindow(
int window_index) const {
if (!is_valid())
return NULL;
int handle = 0;
- if (sender_->Send(new AutomationMsg_ConstrainedWindow(0, handle_,
+ if (!sender_->Send(new AutomationMsg_ConstrainedWindow(0, handle_,
window_index,
- &handle))) {
- return new ConstrainedWindowProxy(sender_, tracker_, handle);
+ &handle)))
+ return NULL;
+
+ if (handle == 0)
+ return NULL;
+
+ ConstrainedWindowProxy* w = static_cast<ConstrainedWindowProxy*>(
+ tracker_->GetResource(handle));
+ if (!w) {
+ w = new ConstrainedWindowProxy(sender_, tracker_, handle);
+ w->AddRef();
}
- return NULL;
+ // Since there is no scoped_refptr::attach.
+ scoped_refptr<ConstrainedWindowProxy> result;
+ result.swap(&w);
+ return result;
}
bool TabProxy::WaitForChildWindowCountToChange(int count, int* new_count,
@@ -637,3 +649,20 @@
}
#endif // defined(OS_WIN)
+
+void TabProxy::AddObserver(TabProxyDelegate* observer) {
+ AutoLock lock(list_lock_);
+ observers_list_.AddObserver(observer);
+}
+
+void TabProxy::RemoveObserver(TabProxyDelegate* observer) {
+ AutoLock lock(list_lock_);
+ observers_list_.RemoveObserver(observer);
+}
+
+// Called on Channel background thread, if TabMessages filter is installed.
+void TabProxy::OnMessageReceived(const IPC::Message& message) {
+ AutoLock lock(list_lock_);
+ FOR_EACH_OBSERVER(TabProxyDelegate, observers_list_,
+ OnMessageReceived(this, message));
+}
« no previous file with comments | « chrome/test/automation/tab_proxy.h ('k') | chrome/test/automation/window_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698