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 ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
6 #define ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
10 #include "base/lazy_instance.h"
11 #include "content/public/browser/resource_dispatcher_host_delegate.h"
14 class ResourceDispatcherHostLoginDelegate
;
15 struct ResourceResponse
;
16 } // namespace content
22 namespace android_webview
{
24 class IoThreadClientThrottle
;
26 class AwResourceDispatcherHostDelegate
27 : public content::ResourceDispatcherHostDelegate
{
29 static void ResourceDispatcherHostCreated();
31 // Overriden methods from ResourceDispatcherHostDelegate.
32 void RequestBeginning(
33 net::URLRequest
* request
,
34 content::ResourceContext
* resource_context
,
35 content::AppCacheService
* appcache_service
,
36 content::ResourceType resource_type
,
37 ScopedVector
<content::ResourceThrottle
>* throttles
) override
;
38 void DownloadStarting(
39 net::URLRequest
* request
,
40 content::ResourceContext
* resource_context
,
44 bool is_content_initiated
,
46 ScopedVector
<content::ResourceThrottle
>* throttles
) override
;
47 content::ResourceDispatcherHostLoginDelegate
* CreateLoginDelegate(
48 net::AuthChallengeInfo
* auth_info
,
49 net::URLRequest
* request
) override
;
50 bool HandleExternalProtocol(const GURL
& url
,
52 int route_id
) override
;
53 void OnResponseStarted(net::URLRequest
* request
,
54 content::ResourceContext
* resource_context
,
55 content::ResourceResponse
* response
,
56 IPC::Sender
* sender
) override
;
58 void OnRequestRedirected(const GURL
& redirect_url
,
59 net::URLRequest
* request
,
60 content::ResourceContext
* resource_context
,
61 content::ResourceResponse
* response
) override
;
63 void RequestComplete(net::URLRequest
* request
) override
;
65 void RemovePendingThrottleOnIoThread(IoThreadClientThrottle
* throttle
);
67 static void OnIoThreadClientReady(int new_render_process_id
,
68 int new_render_frame_id
);
69 static void AddPendingThrottle(int render_process_id
,
71 IoThreadClientThrottle
* pending_throttle
);
74 friend struct base::DefaultLazyInstanceTraits
<
75 AwResourceDispatcherHostDelegate
>;
76 AwResourceDispatcherHostDelegate();
77 ~AwResourceDispatcherHostDelegate() override
;
79 // These methods must be called on IO thread.
80 void OnIoThreadClientReadyInternal(int new_render_process_id
,
81 int new_render_frame_id
);
82 void AddPendingThrottleOnIoThread(int render_process_id
,
84 IoThreadClientThrottle
* pending_throttle
);
85 void AddExtraHeadersIfNeeded(net::URLRequest
* request
,
86 content::ResourceContext
* resource_context
);
88 // Pair of render_process_id and render_frame_id.
89 typedef std::pair
<int, int> FrameRouteIDPair
;
90 typedef std::map
<FrameRouteIDPair
, IoThreadClientThrottle
*>
93 // Only accessed on the IO thread.
94 PendingThrottleMap pending_throttles_
;
96 DISALLOW_COPY_AND_ASSIGN(AwResourceDispatcherHostDelegate
);
99 } // namespace android_webview
101 #endif // ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_H_