[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / loader / stream_resource_handler.h
blob37f4d0da2ea6307ace52e7ba9abbb13243a9aee9
1 // Copyright (c) 2013 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.
5 #ifndef CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "content/browser/loader/resource_handler.h"
11 #include "content/browser/loader/stream_writer.h"
13 namespace net {
14 class URLRequest;
15 } // namespace net
17 namespace content {
19 class StreamRegistry;
21 // Redirect this resource to a stream.
22 class StreamResourceHandler : public ResourceHandler {
23 public:
24 // |origin| will be used to construct the URL for the Stream. See
25 // WebCore::BlobURL and and WebCore::SecurityOrigin in Blink to understand
26 // how origin check is done on resource loading.
27 StreamResourceHandler(net::URLRequest* request,
28 StreamRegistry* registry,
29 const GURL& origin);
30 ~StreamResourceHandler() override;
32 void SetController(ResourceController* controller) override;
34 // Not needed, as this event handler ought to be the final resource.
35 bool OnRequestRedirected(const net::RedirectInfo& redirect_info,
36 ResourceResponse* resp,
37 bool* defer) override;
39 bool OnResponseStarted(ResourceResponse* resp, bool* defer) override;
41 bool OnWillStart(const GURL& url, bool* defer) override;
43 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override;
45 // Create a new buffer to store received data.
46 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf,
47 int* buf_size,
48 int min_size) override;
50 // A read was completed, forward the data to the Stream.
51 bool OnReadCompleted(int bytes_read, bool* defer) override;
53 void OnResponseCompleted(const net::URLRequestStatus& status,
54 const std::string& sec_info,
55 bool* defer) override;
57 void OnDataDownloaded(int bytes_downloaded) override;
59 Stream* stream() { return writer_.stream(); }
61 private:
62 StreamWriter writer_;
64 DISALLOW_COPY_AND_ASSIGN(StreamResourceHandler);
67 } // namespace content
69 #endif // CONTENT_BROWSER_LOADER_STREAM_RESOURCE_HANDLER_H_