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

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

Issue 2703343002: ServiceWorker: Use mojo's data pipe for respondWith(stream) (Closed)
Patch Set: Addressed comments from kinuko and haraken 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 2016 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_STREAM_READER_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STREAM_READER_H_
7
8 #include "content/browser/service_worker/service_worker_url_request_job.h"
9 #include "content/browser/streams/stream_read_observer.h"
10 #include "content/browser/streams/stream_register_observer.h"
11 #include "net/url_request/url_request.h"
12
13 namespace net {
14 class IOBuffer;
15 }
16
17 namespace content {
18
19 class ServiceWorkerVersion;
20
21 // Reads a stream response for ServiceWorkerURLRequestJob.
22 // Owned by ServiceWorkerURLRequestJob.
23 class ServiceWorkerStreamReader : public StreamReadObserver,
24 public StreamRegisterObserver {
25 public:
26 // |streaming_version| is the ServiceWorkerVersion that must be kept alive
27 // while the response is being read.
28 ServiceWorkerStreamReader(
29 ServiceWorkerURLRequestJob* owner,
30 scoped_refptr<ServiceWorkerVersion> streaming_version);
31 ~ServiceWorkerStreamReader() override;
32
33 // Starts reading the stream. owner_->OnResponseStarted will be called when
34 // the response starts.
35 void Start(const GURL& stream_url);
36
37 // Same as URLRequestJob::ReadRawData. If ERR_IO_PENDING is returned,
38 // owner_->OnReadRawDataComplete will be called when the read completes.
39 int ReadRawData(net::IOBuffer* buf, int buf_size);
40
41 // StreamObserver override:
42 void OnDataAvailable(Stream* stream) override;
43
44 // StreamRegisterObserver override:
45 void OnStreamRegistered(Stream* stream) override;
46
47 private:
48 ServiceWorkerURLRequestJob* owner_;
49
50 scoped_refptr<Stream> stream_;
51 GURL waiting_stream_url_;
52 scoped_refptr<net::IOBuffer> stream_pending_buffer_;
53 int stream_pending_buffer_size_;
54
55 scoped_refptr<ServiceWorkerVersion> streaming_version_;
56 };
57
58 } // namespace content
59
60 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_STREAM_READER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698