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_
10 #include "content/browser/loader/resource_handler.h"
11 #include "content/public/common/resource_response.h"
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 {
31 SyncResourceHandler(net::URLRequest* request,
32 IPC::Message* result_message,
33 ResourceDispatcherHostImpl* resource_dispatcher_host);
34 virtual ~SyncResourceHandler();
36 virtual bool OnUploadProgress(int request_id,
38 uint64 size) OVERRIDE;
39 virtual bool OnRequestRedirected(int request_id,
41 ResourceResponse* response,
42 bool* defer) OVERRIDE;
43 virtual bool OnResponseStarted(int request_id,
44 ResourceResponse* response,
45 bool* defer) OVERRIDE;
46 virtual bool OnWillStart(int request_id,
48 bool* defer) OVERRIDE;
49 virtual bool OnWillRead(int request_id,
50 scoped_refptr<net::IOBuffer>* buf,
52 int min_size) OVERRIDE;
53 virtual bool OnReadCompleted(int request_id,
55 bool* defer) OVERRIDE;
56 virtual bool OnResponseCompleted(int request_id,
57 const net::URLRequestStatus& status,
58 const std::string& security_info) OVERRIDE;
59 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE;
62 enum { kReadBufSize = 3840 };
64 scoped_refptr<net::IOBuffer> read_buffer_;
66 SyncLoadResult result_;
67 IPC::Message* result_message_;
68 ResourceDispatcherHostImpl* rdh_;
71 } // namespace content
73 #endif // CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_