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. 4 5 #ifndef CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ 6 #define CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ 7 8 #include <string> 9 10 #include "content/browser/loader/resource_handler.h" 11 #include "content/public/common/resource_response.h" 12 13 namespace IPC { 14 class Message; 15 } 16 17 namespace net { 18 class IOBuffer; 19 class URLRequest; 20 } 21 22 namespace content { 23 class ResourceContext; 24 class ResourceDispatcherHostImpl; 25 class ResourceMessageFilter; 26 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 virtual ~SyncResourceHandler(); 35 36 virtual bool OnUploadProgress(uint64 position, uint64 size) OVERRIDE; 37 virtual bool OnRequestRedirected(const net::RedirectInfo& redirect_info, 38 ResourceResponse* response, 39 bool* defer) OVERRIDE; 40 virtual bool OnResponseStarted(ResourceResponse* response, 41 bool* defer) OVERRIDE; 42 virtual bool OnWillStart(const GURL& url, bool* defer) OVERRIDE; 43 virtual bool OnBeforeNetworkStart(const GURL& url, bool* defer) OVERRIDE; 44 virtual bool OnWillRead(scoped_refptr<net::IOBuffer>* buf, 45 int* buf_size, 46 int min_size) OVERRIDE; 47 virtual bool OnReadCompleted(int bytes_read, bool* defer) OVERRIDE; 48 virtual void OnResponseCompleted(const net::URLRequestStatus& status, 49 const std::string& security_info, 50 bool* defer) OVERRIDE; 51 virtual void OnDataDownloaded(int bytes_downloaded) OVERRIDE; 52 53 private: 54 enum { kReadBufSize = 3840 }; 55 56 scoped_refptr<net::IOBuffer> read_buffer_; 57 58 SyncLoadResult result_; 59 IPC::Message* result_message_; 60 ResourceDispatcherHostImpl* rdh_; 61 int64 total_transfer_size_; 62 }; 63 64 } // namespace content 65 66 #endif // CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ 67