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

Side by Side Diff: chrome/test/automation/automation_proxy.cc

Issue 5707006: Revert "Add named testing interface." (Closed)
Patch Set: Created 10 years 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 unified diff | Download patch
OLDNEW
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/automation_proxy.h" 5 #include "chrome/test/automation/automation_proxy.h"
6 6
7 #include <gtest/gtest.h> 7 #include <gtest/gtest.h>
8 8
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 perform_version_check_(false), 100 perform_version_check_(false),
101 disconnect_on_failure_(disconnect_on_failure), 101 disconnect_on_failure_(disconnect_on_failure),
102 command_execution_timeout_( 102 command_execution_timeout_(
103 TimeDelta::FromMilliseconds(command_execution_timeout_ms)), 103 TimeDelta::FromMilliseconds(command_execution_timeout_ms)),
104 listener_thread_id_(0) { 104 listener_thread_id_(0) {
105 // base::WaitableEvent::TimedWait() will choke if we give it a negative value. 105 // base::WaitableEvent::TimedWait() will choke if we give it a negative value.
106 // Zero also seems unreasonable, since we need to wait for IPC, but at 106 // Zero also seems unreasonable, since we need to wait for IPC, but at
107 // least it is legal... ;-) 107 // least it is legal... ;-)
108 DCHECK_GE(command_execution_timeout_ms, 0); 108 DCHECK_GE(command_execution_timeout_ms, 0);
109 listener_thread_id_ = PlatformThread::CurrentId(); 109 listener_thread_id_ = PlatformThread::CurrentId();
110 InitializeChannelID();
110 InitializeHandleTracker(); 111 InitializeHandleTracker();
111 InitializeThread(); 112 InitializeThread();
113 InitializeChannel();
112 } 114 }
113 115
114 AutomationProxy::~AutomationProxy() { 116 AutomationProxy::~AutomationProxy() {
115 // Destruction order is important. Thread has to outlive the channel and 117 // Destruction order is important. Thread has to outlive the channel and
116 // tracker has to outlive the thread since we access the tracker inside 118 // tracker has to outlive the thread since we access the tracker inside
117 // AutomationMessageFilter::OnMessageReceived. 119 // AutomationMessageFilter::OnMessageReceived.
118 Disconnect(); 120 Disconnect();
119 thread_.reset(); 121 thread_.reset();
120 tracker_.reset(); 122 tracker_.reset();
121 } 123 }
122 124
123 std::string AutomationProxy::GenerateChannelID() { 125 void AutomationProxy::InitializeChannelID() {
124 // The channel counter keeps us out of trouble if we create and destroy 126 // The channel counter keeps us out of trouble if we create and destroy
125 // several AutomationProxies sequentially over the course of a test run. 127 // several AutomationProxies sequentially over the course of a test run.
126 // (Creating the channel sometimes failed before when running a lot of 128 // (Creating the channel sometimes failed before when running a lot of
127 // tests in sequence, and our theory is that sometimes the channel ID 129 // tests in sequence, and our theory is that sometimes the channel ID
128 // wasn't getting freed up in time for the next test.) 130 // wasn't getting freed up in time for the next test.)
129 static int channel_counter = 0; 131 static int channel_counter = 0;
130 132
131 std::ostringstream buf; 133 std::ostringstream buf;
132 buf << "ChromeTestingInterface:" << base::GetCurrentProcId() << 134 buf << "ChromeTestingInterface:" << base::GetCurrentProcId() <<
133 "." << ++channel_counter; 135 "." << ++channel_counter;
134 return buf.str(); 136 channel_id_ = buf.str();
135 } 137 }
136 138
137 void AutomationProxy::InitializeThread() { 139 void AutomationProxy::InitializeThread() {
138 scoped_ptr<base::Thread> thread( 140 scoped_ptr<base::Thread> thread(
139 new base::Thread("AutomationProxy_BackgroundThread")); 141 new base::Thread("AutomationProxy_BackgroundThread"));
140 base::Thread::Options options; 142 base::Thread::Options options;
141 options.message_loop_type = MessageLoop::TYPE_IO; 143 options.message_loop_type = MessageLoop::TYPE_IO;
142 bool thread_result = thread->StartWithOptions(options); 144 bool thread_result = thread->StartWithOptions(options);
143 DCHECK(thread_result); 145 DCHECK(thread_result);
144 thread_.swap(thread); 146 thread_.swap(thread);
145 } 147 }
146 148
147 void AutomationProxy::InitializeChannel(const std::string& channel_id, 149 void AutomationProxy::InitializeChannel() {
148 bool use_named_interface) {
149 DCHECK(shutdown_event_.get() != NULL); 150 DCHECK(shutdown_event_.get() != NULL);
150 151
151 // TODO(iyengar) 152 // TODO(iyengar)
152 // The shutdown event could be global on the same lines as the automation 153 // The shutdown event could be global on the same lines as the automation
153 // provider, where we use the shutdown event provided by the chrome browser 154 // provider, where we use the shutdown event provided by the chrome browser
154 // process. 155 // process.
155 channel_.reset(new IPC::SyncChannel( 156 channel_.reset(new IPC::SyncChannel(
156 channel_id, 157 channel_id_,
157 use_named_interface ? IPC::Channel::MODE_NAMED_CLIENT 158 IPC::Channel::MODE_SERVER,
158 : IPC::Channel::MODE_SERVER,
159 this, // we are the listener 159 this, // we are the listener
160 thread_->message_loop(), 160 thread_->message_loop(),
161 true, 161 true,
162 shutdown_event_.get())); 162 shutdown_event_.get()));
163 channel_->AddFilter(new AutomationMessageFilter(this)); 163 channel_->AddFilter(new AutomationMessageFilter(this));
164 } 164 }
165 165
166 void AutomationProxy::InitializeHandleTracker() { 166 void AutomationProxy::InitializeHandleTracker() {
167 tracker_.reset(new AutomationHandleTracker()); 167 tracker_.reset(new AutomationHandleTracker());
168 } 168 }
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 password, 543 password,
544 &success)); 544 &success));
545 // If message sending unsuccessful or test failed, return false. 545 // If message sending unsuccessful or test failed, return false.
546 return sent && success; 546 return sent && success;
547 } 547 }
548 #endif 548 #endif
549 549
550 bool AutomationProxy::ResetToDefaultTheme() { 550 bool AutomationProxy::ResetToDefaultTheme() {
551 return Send(new AutomationMsg_ResetToDefaultTheme(0)); 551 return Send(new AutomationMsg_ResetToDefaultTheme(0));
552 } 552 }
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_proxy.h ('k') | chrome/test/automation/automation_proxy_uitest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698