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(int request_id, 37 uint64 position, 38 uint64 size) OVERRIDE; 39 virtual bool OnRequestRedirected(int request_id, 40 const GURL& new_url, 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, 47 const GURL& url, 48 bool* defer) OVERRIDE; 49 virtual bool OnWillRead(int request_id, 50 scoped_refptr<net::IOBuffer>* buf, 51 int* buf_size, 52 int min_size) OVERRIDE; 53 virtual bool OnReadCompleted(int request_id, 54 int bytes_read, 55 bool* defer) OVERRIDE; 56 virtual void OnResponseCompleted(int request_id, 57 const net::URLRequestStatus& status, 58 const std::string& security_info, 59 bool* defer) OVERRIDE; 60 virtual void OnDataDownloaded(int request_id, int bytes_downloaded) OVERRIDE; 61 62 private: 63 enum { kReadBufSize = 3840 }; 64 65 scoped_refptr<net::IOBuffer> read_buffer_; 66 67 SyncLoadResult result_; 68 IPC::Message* result_message_; 69 ResourceDispatcherHostImpl* rdh_; 70 }; 71 72 } // namespace content 73 74 #endif // CONTENT_BROWSER_LOADER_SYNC_RESOURCE_HANDLER_H_ 75