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

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

Issue 2021393004: Migrate WaitableEvent to enum-based constructor in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@WEvent_enums
Patch Set: Split out custom changes to thread_watcher_unittest.cc Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/sync_websocket_impl.h" 5 #include "chrome/test/chromedriver/net/sync_websocket_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 is_connected_(false), 46 is_connected_(false),
47 on_update_event_(&lock_) {} 47 on_update_event_(&lock_) {}
48 48
49 bool SyncWebSocketImpl::Core::IsConnected() { 49 bool SyncWebSocketImpl::Core::IsConnected() {
50 base::AutoLock lock(lock_); 50 base::AutoLock lock(lock_);
51 return is_connected_; 51 return is_connected_;
52 } 52 }
53 53
54 bool SyncWebSocketImpl::Core::Connect(const GURL& url) { 54 bool SyncWebSocketImpl::Core::Connect(const GURL& url) {
55 bool success = false; 55 bool success = false;
56 base::WaitableEvent event(false, false); 56 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
57 base::WaitableEvent::InitialState::NOT_SIGNALED);
57 context_getter_->GetNetworkTaskRunner()->PostTask( 58 context_getter_->GetNetworkTaskRunner()->PostTask(
58 FROM_HERE, 59 FROM_HERE,
59 base::Bind(&SyncWebSocketImpl::Core::ConnectOnIO, 60 base::Bind(&SyncWebSocketImpl::Core::ConnectOnIO,
60 this, url, &success, &event)); 61 this, url, &success, &event));
61 event.Wait(); 62 event.Wait();
62 return success; 63 return success;
63 } 64 }
64 65
65 bool SyncWebSocketImpl::Core::Send(const std::string& message) { 66 bool SyncWebSocketImpl::Core::Send(const std::string& message) {
66 bool success = false; 67 bool success = false;
67 base::WaitableEvent event(false, false); 68 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
69 base::WaitableEvent::InitialState::NOT_SIGNALED);
68 context_getter_->GetNetworkTaskRunner()->PostTask( 70 context_getter_->GetNetworkTaskRunner()->PostTask(
69 FROM_HERE, 71 FROM_HERE,
70 base::Bind(&SyncWebSocketImpl::Core::SendOnIO, 72 base::Bind(&SyncWebSocketImpl::Core::SendOnIO,
71 this, message, &success, &event)); 73 this, message, &success, &event));
72 event.Wait(); 74 event.Wait();
73 return success; 75 return success;
74 } 76 }
75 77
76 SyncWebSocket::StatusCode SyncWebSocketImpl::Core::ReceiveNextMessage( 78 SyncWebSocket::StatusCode SyncWebSocketImpl::Core::ReceiveNextMessage(
77 std::string* message, 79 std::string* message,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 146 }
145 147
146 void SyncWebSocketImpl::Core::OnDestruct() const { 148 void SyncWebSocketImpl::Core::OnDestruct() const {
147 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner = 149 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner =
148 context_getter_->GetNetworkTaskRunner(); 150 context_getter_->GetNetworkTaskRunner();
149 if (network_task_runner->BelongsToCurrentThread()) 151 if (network_task_runner->BelongsToCurrentThread())
150 delete this; 152 delete this;
151 else 153 else
152 network_task_runner->DeleteSoon(FROM_HERE, this); 154 network_task_runner->DeleteSoon(FROM_HERE, this);
153 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698