| 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 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include "base/ios/block_types.h" | 9 #include "base/ios/block_types.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 242 |
| 243 std::unique_ptr<base::Value> MojoFacade::HandleSupportWatch( | 243 std::unique_ptr<base::Value> MojoFacade::HandleSupportWatch( |
| 244 const base::DictionaryValue* args) { | 244 const base::DictionaryValue* args) { |
| 245 int handle = 0; | 245 int handle = 0; |
| 246 CHECK(args->GetInteger("handle", &handle)); | 246 CHECK(args->GetInteger("handle", &handle)); |
| 247 int signals = 0; | 247 int signals = 0; |
| 248 CHECK(args->GetInteger("signals", &signals)); | 248 CHECK(args->GetInteger("signals", &signals)); |
| 249 int callback_id; | 249 int callback_id; |
| 250 CHECK(args->GetInteger("callbackId", &callback_id)); | 250 CHECK(args->GetInteger("callbackId", &callback_id)); |
| 251 | 251 |
| 252 mojo::Watcher::ReadyCallback callback = base::BindBlock(^(MojoResult result) { | 252 mojo::Watcher::ReadyCallback callback = base::BindBlockArc(^( |
| 253 MojoResult result) { |
| 253 NSString* script = | 254 NSString* script = |
| 254 [NSString stringWithFormat:@"__crWeb.mojo.signalWatch(%d, %d)", | 255 [NSString stringWithFormat:@"__crWeb.mojo.signalWatch(%d, %d)", |
| 255 callback_id, result]; | 256 callback_id, result]; |
| 256 [script_evaluator_ executeJavaScript:script completionHandler:nil]; | 257 [script_evaluator_ executeJavaScript:script completionHandler:nil]; |
| 257 }); | 258 }); |
| 258 | 259 |
| 259 mojo::Watcher& watcher = watchers_[++last_watch_id_]; | 260 mojo::Watcher& watcher = watchers_[++last_watch_id_]; |
| 260 watcher.Start(static_cast<mojo::Handle>(handle), signals, callback); | 261 watcher.Start(static_cast<mojo::Handle>(handle), signals, callback); |
| 261 return ValueFromInteger(last_watch_id_); | 262 return ValueFromInteger(last_watch_id_); |
| 262 } | 263 } |
| 263 | 264 |
| 264 std::unique_ptr<base::Value> MojoFacade::HandleSupportCancelWatch( | 265 std::unique_ptr<base::Value> MojoFacade::HandleSupportCancelWatch( |
| 265 const base::DictionaryValue* args) { | 266 const base::DictionaryValue* args) { |
| 266 int watch_id = 0; | 267 int watch_id = 0; |
| 267 CHECK(args->GetInteger("watchId", &watch_id)); | 268 CHECK(args->GetInteger("watchId", &watch_id)); |
| 268 watchers_.erase(watch_id); | 269 watchers_.erase(watch_id); |
| 269 return nullptr; | 270 return nullptr; |
| 270 } | 271 } |
| 271 | 272 |
| 272 } // namespace web | 273 } // namespace web |
| OLD | NEW |