Index: third_party/grpc/src/php/lib/Grpc/ClientStreamingCall.php |
diff --git a/third_party/WebKit/Source/devtools/front_end/common/TextDictionary.js b/third_party/grpc/src/php/lib/Grpc/ClientStreamingCall.php |
similarity index 50% |
copy from third_party/WebKit/Source/devtools/front_end/common/TextDictionary.js |
copy to third_party/grpc/src/php/lib/Grpc/ClientStreamingCall.php |
index 76abb697f89214671d4865fee58a17e1bf6bb79e..500cfe0d7a0a3e6421ad43cb817c4d5ea6aeeb12 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/common/TextDictionary.js |
+++ b/third_party/grpc/src/php/lib/Grpc/ClientStreamingCall.php |
@@ -1,5 +1,8 @@ |
+<?php |
/* |
- * Copyright (C) 2013 Google Inc. 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 |
@@ -26,75 +29,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. |
+ * |
*/ |
+namespace Grpc; |
+ |
/** |
- * @constructor |
+ * Represents an active call that sends a stream of messages and then gets a |
+ * single response. |
*/ |
-WebInspector.TextDictionary = function() |
+class ClientStreamingCall extends AbstractCall |
{ |
- this._words = {}; |
-} |
- |
-WebInspector.TextDictionary.prototype = { |
- /** |
- * @param {string} word |
- */ |
- addWord: function(word) |
- { |
- if (!this._words[word]) |
- this._words[word] = 1; |
- else |
- ++this._words[word]; |
- }, |
- |
/** |
- * @param {string} word |
+ * Start the call. |
+ * |
+ * @param array $metadata Metadata to send with the call, if applicable |
*/ |
- removeWord: function(word) |
+ public function start($metadata = []) |
{ |
- if (!this._words[word]) |
- return; |
- if (this._words[word] === 1) |
- delete this._words[word]; |
- else |
- --this._words[word]; |
- }, |
+ $this->call->startBatch([ |
+ OP_SEND_INITIAL_METADATA => $metadata, |
+ ]); |
+ } |
/** |
- * @param {string} prefix |
- * @return {!Array.<string>} |
+ * Write a single message to the server. This cannot be called after |
+ * wait is called. |
+ * |
+ * @param ByteBuffer $data The data to write |
+ * @param array $options an array of options, possible keys: |
+ * 'flags' => a number |
*/ |
- wordsWithPrefix: function(prefix) |
+ public function write($data, $options = []) |
{ |
- var words = []; |
- for (var i in this._words) { |
- if (i.startsWith(prefix)) |
- words.push(i); |
+ $message_array = ['message' => $data->serialize()]; |
+ if (isset($options['flags'])) { |
+ $message_array['flags'] = $options['flags']; |
} |
- return words; |
- }, |
- |
- /** |
- * @param {string} word |
- * @return {boolean} |
- */ |
- hasWord: function(word) |
- { |
- return !!this._words[word]; |
- }, |
+ $this->call->startBatch([ |
+ OP_SEND_MESSAGE => $message_array, |
+ ]); |
+ } |
/** |
- * @param {string} word |
- * @return {number} |
+ * Wait for the server to respond with data and a status. |
+ * |
+ * @return [response data, status] |
*/ |
- wordCount: function(word) |
+ public function wait() |
{ |
- return this._words[word] ? this._words[word] : 0; |
- }, |
+ $event = $this->call->startBatch([ |
+ OP_SEND_CLOSE_FROM_CLIENT => true, |
+ OP_RECV_INITIAL_METADATA => true, |
+ OP_RECV_MESSAGE => true, |
+ OP_RECV_STATUS_ON_CLIENT => true, |
+ ]); |
+ $this->metadata = $event->metadata; |
- reset: function() |
- { |
- this._words = {}; |
+ return [$this->deserializeResponse($event->message), $event->status]; |
} |
} |