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

Unified Diff: third_party/grpc/src/objective-c/RxLibrary/GRXWriteable.m

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « third_party/grpc/src/objective-c/RxLibrary/GRXWriteable.h ('k') | third_party/grpc/src/objective-c/RxLibrary/GRXWriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698