OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/web/webui/mojo_facade.h" | 5 #import "ios/web/webui/mojo_facade.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
10 | 10 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 std::unique_ptr<base::Value> MojoFacade::HandleSupportWatch( | 246 std::unique_ptr<base::Value> MojoFacade::HandleSupportWatch( |
247 const base::DictionaryValue* args) { | 247 const base::DictionaryValue* args) { |
248 int handle = 0; | 248 int handle = 0; |
249 CHECK(args->GetInteger("handle", &handle)); | 249 CHECK(args->GetInteger("handle", &handle)); |
250 int signals = 0; | 250 int signals = 0; |
251 CHECK(args->GetInteger("signals", &signals)); | 251 CHECK(args->GetInteger("signals", &signals)); |
252 int callback_id; | 252 int callback_id; |
253 CHECK(args->GetInteger("callbackId", &callback_id)); | 253 CHECK(args->GetInteger("callbackId", &callback_id)); |
254 | 254 |
255 mojo::Watcher::ReadyCallback callback = base::BindBlockArc(^( | 255 mojo::SimpleWatcher::ReadyCallback callback = base::BindBlockArc(^( |
256 MojoResult result) { | 256 MojoResult result) { |
257 NSString* script = | 257 NSString* script = |
258 [NSString stringWithFormat:@"__crWeb.mojo.signalWatch(%d, %d)", | 258 [NSString stringWithFormat:@"__crWeb.mojo.signalWatch(%d, %d)", |
259 callback_id, result]; | 259 callback_id, result]; |
260 [script_evaluator_ executeJavaScript:script completionHandler:nil]; | 260 [script_evaluator_ executeJavaScript:script completionHandler:nil]; |
261 }); | 261 }); |
262 mojo::Watcher* watcher = new mojo::Watcher(FROM_HERE); | 262 mojo::SimpleWatcher* watcher = new mojo::SimpleWatcher( |
| 263 FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::AUTOMATIC); |
263 watchers_.insert(std::make_pair(++last_watch_id_, base::WrapUnique(watcher))); | 264 watchers_.insert(std::make_pair(++last_watch_id_, base::WrapUnique(watcher))); |
264 watcher->Start(static_cast<mojo::Handle>(handle), signals, callback); | 265 watcher->Watch(static_cast<mojo::Handle>(handle), signals, callback); |
265 return ValueFromInteger(last_watch_id_); | 266 return ValueFromInteger(last_watch_id_); |
266 } | 267 } |
267 | 268 |
268 std::unique_ptr<base::Value> MojoFacade::HandleSupportCancelWatch( | 269 std::unique_ptr<base::Value> MojoFacade::HandleSupportCancelWatch( |
269 const base::DictionaryValue* args) { | 270 const base::DictionaryValue* args) { |
270 int watch_id = 0; | 271 int watch_id = 0; |
271 CHECK(args->GetInteger("watchId", &watch_id)); | 272 CHECK(args->GetInteger("watchId", &watch_id)); |
272 watchers_.erase(watch_id); | 273 watchers_.erase(watch_id); |
273 return nullptr; | 274 return nullptr; |
274 } | 275 } |
275 | 276 |
276 } // namespace web | 277 } // namespace web |
OLD | NEW |