1 // Copyright (c) 2013 Intel Corporation. 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 XWALK_RUNTIME_BROWSER_RUNTIME_RESOURCE_DISPATCHER_HOST_DELEGATE_ANDROID_H_
6 #define XWALK_RUNTIME_BROWSER_RUNTIME_RESOURCE_DISPATCHER_HOST_DELEGATE_ANDROID_H_
11 #include "base/lazy_instance.h"
12 #include "content/public/browser/content_browser_client.h"
13 #include "xwalk/runtime/browser/runtime_resource_dispatcher_host_delegate.h"
16 class ResourceDispatcherHostLoginDelegate;
17 struct ResourceResponse;
18 } // namespace content
26 class IoThreadClientThrottle;
28 class RuntimeResourceDispatcherHostDelegateAndroid
29 : public RuntimeResourceDispatcherHostDelegate {
31 RuntimeResourceDispatcherHostDelegateAndroid();
32 virtual ~RuntimeResourceDispatcherHostDelegateAndroid();
34 static void ResourceDispatcherHostCreated();
36 virtual void RequestBeginning(
37 net::URLRequest* request,
38 content::ResourceContext* resource_context,
39 appcache::AppCacheService* appcache_service,
40 ResourceType::Type resource_type,
43 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
44 virtual void DownloadStarting(
45 net::URLRequest* request,
46 content::ResourceContext* resource_context,
50 bool is_content_initiated,
52 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
53 virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
54 net::AuthChallengeInfo* auth_info,
55 net::URLRequest* request) OVERRIDE;
56 virtual bool HandleExternalProtocol(
59 int route_id) OVERRIDE;
60 virtual void OnResponseStarted(
61 net::URLRequest* request,
62 content::ResourceContext* resource_context,
63 content::ResourceResponse* response,
64 IPC::Sender* sender) OVERRIDE;
66 void RemovePendingThrottleOnIoThread(IoThreadClientThrottle* throttle);
68 static void OnIoThreadClientReady(int new_render_process_id,
69 int new_render_frame_id);
70 static void AddPendingThrottle(int render_process_id,
72 IoThreadClientThrottle* pending_throttle);
74 friend struct base::DefaultLazyInstanceTraits<
75 RuntimeResourceDispatcherHostDelegateAndroid>;
76 // These methods must be called on IO thread.
77 void OnIoThreadClientReadyInternal(int new_render_process_id,
78 int new_render_frame_id);
79 void AddPendingThrottleOnIoThread(int render_process_id,
81 IoThreadClientThrottle* pending_throttle);
83 typedef std::pair<int, int> FrameRouteIDPair;
84 typedef std::map<FrameRouteIDPair, IoThreadClientThrottle*>
87 // Only accessed on the IO thread.
88 PendingThrottleMap pending_throttles_;
90 DISALLOW_COPY_AND_ASSIGN(RuntimeResourceDispatcherHostDelegateAndroid);
95 #endif // XWALK_RUNTIME_BROWSER_RUNTIME_RESOURCE_DISPATCHER_HOST_DELEGATE_ANDROID_H_