[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / loader / sync_resource_handler.h
blobfb028475fbbf3b7ae44a02c37286b4acb94710a6
1 // Copyright (c) 2012 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_SYNC_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_
8 #include <string>
10 #include "content/browser/loader/resource_handler.h"
11 #include "content/public/common/resource_response.h"
13 namespace IPC {
14 class Message;
17 namespace net {
18 class IOBuffer;
19 class URLRequest;
22 namespace content {
23 class ResourceContext;
24 class ResourceDispatcherHostImpl;
25 class ResourceMessageFilter;
27 // Used to complete a synchronous resource request in response to resource load
28 // events from the resource dispatcher host.
29 class SyncResourceHandler : public ResourceHandler {
30 public:
31 SyncResourceHandler(net::URLRequest* request,
32 IPC::Message* result_message,
33 ResourceDispatcherHostImpl* resource_dispatcher_host);
34 ~SyncResourceHandler() override;
36 bool OnRequestRedirected(const net::RedirectInfo& redirect_info,
37 ResourceResponse* response,
38 bool* defer) override;
39 bool OnResponseStarted(ResourceResponse* response, bool* defer) override;
40 bool OnWillStart(const GURL& url, bool* defer) override;
41 bool OnBeforeNetworkStart(const GURL& url, bool* defer) override;
42 bool OnWillRead(scoped_refptr<net::IOBuffer>* buf,
43 int* buf_size,
44 int min_size) override;
45 bool OnReadCompleted(int bytes_read, bool* defer) override;
46 void OnResponseCompleted(const net::URLRequestStatus& status,
47 const std::string& security_info,
48 bool* defer) override;
49 void OnDataDownloaded(int bytes_downloaded) override;
51 private:
52 enum { kReadBufSize = 3840 };
54 scoped_refptr<net::IOBuffer> read_buffer_;
56 SyncLoadResult result_;
57 IPC::Message* result_message_;
58 ResourceDispatcherHostImpl* rdh_;
59 int64 total_transfer_size_;
62 } // namespace content
64 #endif // CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_