| Index: third_party/grpc/src/objective-c/RxLibrary/GRXWriteable.m
|
| diff --git a/third_party/WebKit/Source/core/frame/DOMWindowBase64.h b/third_party/grpc/src/objective-c/RxLibrary/GRXWriteable.m
|
| similarity index 53%
|
| copy from third_party/WebKit/Source/core/frame/DOMWindowBase64.h
|
| copy to third_party/grpc/src/objective-c/RxLibrary/GRXWriteable.m
|
| index 2854ab37f6c60b55829ea7d87985e91696f8aa9f..2729d62b72f2c174f6fc2fa217af22093d847837 100644
|
| --- a/third_party/WebKit/Source/core/frame/DOMWindowBase64.h
|
| +++ b/third_party/grpc/src/objective-c/RxLibrary/GRXWriteable.m
|
| @@ -1,7 +1,7 @@
|
| /*
|
| - * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
|
| - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
|
| - * Copyright (C) 2013 Samsung Electronics. All rights reserved.
|
| + *
|
| + * Copyright 2015, Google Inc.
|
| + * All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| * modification, are permitted provided that the following conditions are
|
| @@ -28,23 +28,63 @@
|
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| + *
|
| */
|
|
|
| -#ifndef DOMWindowBase64_h
|
| -#define DOMWindowBase64_h
|
| +#import "GRXWriteable.h"
|
| +
|
| +@implementation GRXWriteable {
|
| + GRXValueHandler _valueHandler;
|
| + GRXCompletionHandler _completionHandler;
|
| +}
|
|
|
| -#include "wtf/text/WTFString.h"
|
| ++ (instancetype)writeableWithSingleHandler:(GRXSingleHandler)handler {
|
| + if (!handler) {
|
| + return [[self alloc] init];
|
| + }
|
| + return [[self alloc] initWithValueHandler:^(id value) {
|
| + handler(value, nil);
|
| + } completionHandler:^(NSError *errorOrNil) {
|
| + if (errorOrNil) {
|
| + handler(nil, errorOrNil);
|
| + }
|
| + }];
|
| +}
|
|
|
| -namespace blink {
|
| ++ (instancetype)writeableWithEventHandler:(GRXEventHandler)handler {
|
| + if (!handler) {
|
| + return [[self alloc] init];
|
| + }
|
| + return [[self alloc] initWithValueHandler:^(id value) {
|
| + handler(NO, value, nil);
|
| + } completionHandler:^(NSError *errorOrNil) {
|
| + handler(YES, nil, errorOrNil);
|
| + }];
|
| +}
|
|
|
| -class ExceptionState;
|
| +- (instancetype)init {
|
| + return [self initWithValueHandler:nil completionHandler:nil];
|
| +}
|
|
|
| -class DOMWindowBase64 {
|
| -public:
|
| - String btoa(const String& stringToEncode, ExceptionState&);
|
| - String atob(const String& encodedString, ExceptionState&);
|
| -};
|
| +// Designated initializer
|
| +- (instancetype)initWithValueHandler:(GRXValueHandler)valueHandler
|
| + completionHandler:(GRXCompletionHandler)completionHandler {
|
| + if ((self = [super init])) {
|
| + _valueHandler = valueHandler;
|
| + _completionHandler = completionHandler;
|
| + }
|
| + return self;
|
| +}
|
|
|
| -} // namespace blink
|
| +- (void)writeValue:(id)value {
|
| + if (_valueHandler) {
|
| + _valueHandler(value);
|
| + }
|
| +}
|
|
|
| -#endif // DOMWindowBase64_h
|
| +- (void)writesFinishedWithError:(NSError *)errorOrNil {
|
| + if (_completionHandler) {
|
| + _completionHandler(errorOrNil);
|
| + }
|
| +}
|
| +@end
|
|
|