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

Side by Side Diff: mojo/services/network/public/cpp/web_socket_write_queue.h

Issue 1873463003: Remove mojo network service. (Closed) 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MOJO_SERVICES_NETWORK_PUBLIC_CPP_WEB_SOCKET_WRITE_QUEUE_H_
6 #define MOJO_SERVICES_NETWORK_PUBLIC_CPP_WEB_SOCKET_WRITE_QUEUE_H_
7
8 #include <stdint.h>
9
10 #include "base/callback.h"
11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h"
13 #include "mojo/message_pump/handle_watcher.h"
14 #include "mojo/public/cpp/system/data_pipe.h"
15
16 namespace mojo {
17
18 // This class simplifies the handling of multiple Writes on a DataPipe. It
19 // writes each chunk all at once (or waits until the pipe is ready before
20 // writing), calling the callback when finished. Callbacks are owned by this
21 // class, and are guaranteed not to be called after this class is destroyed.
22 // See also: WebSocketReadQueue
23 class WebSocketWriteQueue {
24 public:
25 explicit WebSocketWriteQueue(DataPipeProducerHandle handle);
26 ~WebSocketWriteQueue();
27
28 void Write(const char* data,
29 uint32_t num_bytes,
30 base::Callback<void(const char*)> callback);
31
32 private:
33 struct Operation;
34
35 void TryToWrite();
36 void Wait();
37 void OnHandleReady(MojoResult result);
38
39 DataPipeProducerHandle handle_;
40 common::HandleWatcher handle_watcher_;
41 ScopedVector<Operation> queue_;
42 bool is_busy_;
43 base::WeakPtrFactory<WebSocketWriteQueue> weak_factory_;
44 };
45
46 } // namespace mojo
47
48 #endif // MOJO_SERVICES_NETWORK_PUBLIC_CPP_WEB_SOCKET_WRITE_QUEUE_H_
OLDNEW
« no previous file with comments | « mojo/services/network/public/cpp/web_socket_read_queue.cc ('k') | mojo/services/network/public/cpp/web_socket_write_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698