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

Side by Side Diff: content/browser/service_worker/service_worker_data_pipe_reader.h

Issue 2703343002: ServiceWorker: Use mojo's data pipe for respondWith(stream) (Closed)
Patch Set: Rebase Created 3 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 2017 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 CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATA_PIPE_READER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATA_PIPE_READER_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "mojo/public/cpp/bindings/binding.h"
10 #include "mojo/public/cpp/system/data_pipe.h"
11 #include "mojo/public/cpp/system/simple_watcher.h"
12 #include "third_party/WebKit/public/platform/modules/serviceworker/service_worke r_stream_handle.mojom.h"
13
14 namespace net {
15 class IOBuffer;
16 } // namespace net
17
18 namespace content {
19
20 class ServiceWorkerURLRequestJob;
21 class ServiceWorkerVersion;
22
23 class ServiceWorkerDataPipeReader
horo 2017/04/06 05:22:09 Can you have unittests for this class?
shimazu 2017/04/07 08:52:29 Done.
24 : public blink::mojom::ServiceWorkerStreamCallback {
25 public:
26 ServiceWorkerDataPipeReader(
27 ServiceWorkerURLRequestJob* owner,
28 scoped_refptr<ServiceWorkerVersion> streaming_version,
29 blink::mojom::ServiceWorkerStreamHandlePtr stream_handle);
30 ~ServiceWorkerDataPipeReader() override;
31 void Start();
32 void OnHandleGotReadable(MojoResult);
horo 2017/04/06 05:22:09 private?
shimazu 2017/04/07 08:52:29 Done.
33 int ReadRawData(net::IOBuffer* buf, int buf_size);
horo 2017/04/06 05:22:09 Please add comments about these methods.
shimazu 2017/04/07 08:52:29 Done.
34
35 // Implements mojom::ServiceWorkerStreamCallback.
36 void OnCompleted() override;
37 void OnAborted() override;
38
39 private:
40 enum class State { STREAMING, COMPLETED, ABORTED };
41
42 void MaybeComplete();
43 void MaybeAbort();
horo 2017/04/06 05:22:09 Delete
shimazu 2017/04/07 08:52:29 Done.
44
45 State state();
46
47 ServiceWorkerURLRequestJob* owner_;
48 scoped_refptr<ServiceWorkerVersion> streaming_version_;
49 scoped_refptr<net::IOBuffer> stream_pending_buffer_;
50 int stream_pending_buffer_size_ = 0;
51 mojo::SimpleWatcher handle_watcher_;
52 mojo::ScopedDataPipeConsumerHandle stream_;
53 mojo::Binding<blink::mojom::ServiceWorkerStreamCallback> binding_;
54 // State notified via ServiceWorkerStreamCallback. |producer_state_| is
55 // STREAMING until OnCompleted or OnAborted is called. Note that |stream_|
56 // might be closed even if |producer_state_| is STREAMING. In order to see the
57 // state of ServiceWorkerDataPipeReader, use state() instead.
58 State producer_state_;
59 };
60
61 } // namespace content
62
63 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_DATA_PIPE_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698