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

Side by Side Diff: chrome/test/chromedriver/net/test_http_server.cc

Issue 12321057: [chromedriver] Implement reconnection to DevTools. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some nits and add one unit test. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/chromedriver/net/test_http_server.h" 5 #include "chrome/test/chromedriver/net/test_http_server.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 25 matching lines...) Expand all
36 base::WaitableEvent event(false, false); 36 base::WaitableEvent event(false, false);
37 thread_.message_loop_proxy()->PostTask( 37 thread_.message_loop_proxy()->PostTask(
38 FROM_HERE, 38 FROM_HERE,
39 base::Bind(&TestHttpServer::StartOnServerThread, 39 base::Bind(&TestHttpServer::StartOnServerThread,
40 base::Unretained(this), &success, &event)); 40 base::Unretained(this), &success, &event));
41 event.Wait(); 41 event.Wait();
42 return success; 42 return success;
43 } 43 }
44 44
45 void TestHttpServer::Stop() { 45 void TestHttpServer::Stop() {
46 if (!server_)
kkania 2013/02/22 01:35:24 although net::HttpServer is ThreadSafeRefCounted,
chrisgao (Use stgao instead) 2013/02/27 19:29:44 Good catch. The check is to avoid calling thread_
47 return;
46 base::WaitableEvent event(false, false); 48 base::WaitableEvent event(false, false);
47 thread_.message_loop_proxy()->PostTask( 49 thread_.message_loop_proxy()->PostTask(
48 FROM_HERE, 50 FROM_HERE,
49 base::Bind(&TestHttpServer::StopOnServerThread, 51 base::Bind(&TestHttpServer::StopOnServerThread,
50 base::Unretained(this), &event)); 52 base::Unretained(this), &event));
51 event.Wait(); 53 event.Wait();
54 thread_.Stop();
52 } 55 }
53 56
54 bool TestHttpServer::WaitForConnectionsToClose() { 57 bool TestHttpServer::WaitForConnectionsToClose() {
55 return all_closed_event_.TimedWait(base::TimeDelta::FromSeconds(10)); 58 return all_closed_event_.TimedWait(base::TimeDelta::FromSeconds(10));
56 } 59 }
57 60
58 void TestHttpServer::SetRequestAction(WebSocketRequestAction action) { 61 void TestHttpServer::SetRequestAction(WebSocketRequestAction action) {
59 base::AutoLock lock(action_lock_); 62 base::AutoLock lock(action_lock_);
60 request_action_ = action; 63 request_action_ = action;
61 } 64 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 143 }
141 *success = server_; 144 *success = server_;
142 event->Signal(); 145 event->Signal();
143 } 146 }
144 147
145 void TestHttpServer::StopOnServerThread(base::WaitableEvent* event) { 148 void TestHttpServer::StopOnServerThread(base::WaitableEvent* event) {
146 if (server_) 149 if (server_)
147 server_ = NULL; 150 server_ = NULL;
148 event->Signal(); 151 event->Signal();
149 } 152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698