OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_DELEGATE_H
_ | 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
_ | 6 #define ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_DELEGATE_H
_ |
7 | 7 |
8 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 8 #include <map> |
9 | 9 |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 class ResourceDispatcherHostLoginDelegate; | 14 class ResourceDispatcherHostLoginDelegate; |
14 } | 15 } |
15 | 16 |
16 namespace android_webview { | 17 namespace android_webview { |
17 | 18 |
| 19 class IoThreadClientThrottle; |
| 20 |
18 class AwResourceDispatcherHostDelegate | 21 class AwResourceDispatcherHostDelegate |
19 : public content::ResourceDispatcherHostDelegate { | 22 : public content::ResourceDispatcherHostDelegate { |
20 public: | 23 public: |
21 static void ResourceDispatcherHostCreated(); | 24 static void ResourceDispatcherHostCreated(); |
22 | 25 |
23 // Overriden methods from ResourceDispatcherHostDelegate. | 26 // Overriden methods from ResourceDispatcherHostDelegate. |
24 virtual void RequestBeginning( | 27 virtual void RequestBeginning( |
25 net::URLRequest* request, | 28 net::URLRequest* request, |
26 content::ResourceContext* resource_context, | 29 content::ResourceContext* resource_context, |
27 appcache::AppCacheService* appcache_service, | 30 appcache::AppCacheService* appcache_service, |
28 ResourceType::Type resource_type, | 31 ResourceType::Type resource_type, |
29 int child_id, | 32 int child_id, |
30 int route_id, | 33 int route_id, |
31 bool is_continuation_of_transferred_request, | 34 bool is_continuation_of_transferred_request, |
32 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE; | 35 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE; |
33 | 36 |
34 virtual bool AcceptAuthRequest(net::URLRequest* request, | 37 virtual bool AcceptAuthRequest(net::URLRequest* request, |
35 net::AuthChallengeInfo* auth_info) OVERRIDE; | 38 net::AuthChallengeInfo* auth_info) OVERRIDE; |
36 | 39 |
37 virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( | 40 virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( |
38 net::AuthChallengeInfo* auth_info, | 41 net::AuthChallengeInfo* auth_info, |
39 net::URLRequest* request) OVERRIDE; | 42 net::URLRequest* request) OVERRIDE; |
40 | 43 |
41 virtual bool HandleExternalProtocol(const GURL& url, | 44 virtual bool HandleExternalProtocol(const GURL& url, |
42 int child_id, | 45 int child_id, |
43 int route_id) OVERRIDE; | 46 int route_id) OVERRIDE; |
44 | 47 |
| 48 void RemovePendingThrottleOnIoThread(IoThreadClientThrottle* throttle); |
| 49 |
| 50 static void OnIoThreadClientReady(int new_child_id, int new_route_id); |
| 51 static void AddPendingThrottle(int child_id, |
| 52 int route_id, |
| 53 IoThreadClientThrottle* pending_throttle); |
| 54 |
45 private: | 55 private: |
46 friend struct base::DefaultLazyInstanceTraits< | 56 friend struct base::DefaultLazyInstanceTraits< |
47 AwResourceDispatcherHostDelegate>; | 57 AwResourceDispatcherHostDelegate>; |
48 AwResourceDispatcherHostDelegate(); | 58 AwResourceDispatcherHostDelegate(); |
49 virtual ~AwResourceDispatcherHostDelegate(); | 59 virtual ~AwResourceDispatcherHostDelegate(); |
50 | 60 |
| 61 // These methods must be called on IO thread. |
| 62 void OnIoThreadClientReadyInternal(int child_id, int route_id); |
| 63 void AddPendingThrottleOnIoThread(int child_id, |
| 64 int route_id, |
| 65 IoThreadClientThrottle* pending_throttle); |
| 66 |
| 67 typedef std::pair<int, int> ChildRouteIDPair; |
| 68 typedef std::map<ChildRouteIDPair, IoThreadClientThrottle*> |
| 69 PendingThrottleMap; |
| 70 |
| 71 // Only accessed on the IO thread. |
| 72 PendingThrottleMap pending_throttles_; |
| 73 |
51 DISALLOW_COPY_AND_ASSIGN(AwResourceDispatcherHostDelegate); | 74 DISALLOW_COPY_AND_ASSIGN(AwResourceDispatcherHostDelegate); |
52 }; | 75 }; |
53 | 76 |
54 } // namespace android_webview | 77 } // namespace android_webview |
55 | 78 |
56 #endif // ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_H_ | 79 #endif // ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_H_ |
OLD | NEW |