Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / content / browser / loader / async_resource_handler.h
blob7a51b77394c96b7704c3fda7556dbc1c96067822
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_ASYNC_RESOURCE_HANDLER_H_
6 #define CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "content/browser/loader/resource_handler.h"
12 #include "content/browser/loader/resource_message_delegate.h"
13 #include "url/gurl.h"
15 namespace net {
16 class URLRequest;
19 namespace content {
20 class ResourceBuffer;
21 class ResourceContext;
22 class ResourceDispatcherHostImpl;
23 class ResourceMessageFilter;
24 class SharedIOBuffer;
26 // Used to complete an asynchronous resource request in response to resource
27 // load events from the resource dispatcher host.
28 class AsyncResourceHandler : public ResourceHandler,
29 public ResourceMessageDelegate {
30 public:
31 AsyncResourceHandler(net::URLRequest* request,
32 ResourceDispatcherHostImpl* rdh);
33 virtual ~AsyncResourceHandler();
35 virtual bool OnMessageReceived(const IPC::Message& message,
36 bool* message_was_ok) OVERRIDE;
38 // ResourceHandler implementation:
39 virtual bool OnUploadProgress(int request_id,
40 uint64 position,
41 uint64 size) OVERRIDE;
42 virtual bool OnRequestRedirected(int request_id,
43 const GURL& new_url,
44 ResourceResponse* response,
45 bool* defer) OVERRIDE;
46 virtual bool OnResponseStarted(int request_id,
47 ResourceResponse* response,
48 bool* defer) OVERRIDE;
49 virtual bool OnWillStart(int request_id,
50 const GURL& url,
51 bool* defer) OVERRIDE;
52 virtual bool OnBeforeNetworkStart(int request_id,
53 const GURL& url,
54 bool* defer) OVERRIDE;
55 virtual bool OnWillRead(int request_id,
56 scoped_refptr<net::IOBuffer>* buf,
57 int* buf_size,
58 int min_size) OVERRIDE;
59 virtual bool OnReadCompleted(int request_id,
60 int bytes_read,
61 bool* defer) OVERRIDE;
62 virtual void OnResponseCompleted(int request_id,
63 const net::URLRequestStatus& status,
64 const std::string& security_info,
65 bool* defer) OVERRIDE;
66 virtual void OnDataDownloaded(int request_id,
67 int bytes_downloaded) OVERRIDE;
69 private:
70 // IPC message handlers:
71 void OnFollowRedirect(int request_id,
72 bool has_new_first_party_for_cookies,
73 const GURL& new_first_party_for_cookies);
74 void OnDataReceivedACK(int request_id);
76 bool EnsureResourceBufferIsInitialized();
77 void ResumeIfDeferred();
78 void OnDefer();
80 scoped_refptr<ResourceBuffer> buffer_;
81 ResourceDispatcherHostImpl* rdh_;
83 // Number of messages we've sent to the renderer that we haven't gotten an
84 // ACK for. This allows us to avoid having too many messages in flight.
85 int pending_data_count_;
87 int allocation_size_;
89 bool did_defer_;
91 bool has_checked_for_sufficient_resources_;
92 bool sent_received_response_msg_;
93 bool sent_first_data_msg_;
95 int64_t reported_transfer_size_;
97 DISALLOW_COPY_AND_ASSIGN(AsyncResourceHandler);
100 } // namespace content
102 #endif // CONTENT_BROWSER_LOADER_ASYNC_RESOURCE_HANDLER_H_