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(
60 bool initiated_by_user_gesture) OVERRIDE;
61 virtual void OnResponseStarted(
62 net::URLRequest* request,
63 content::ResourceContext* resource_context,
64 content::ResourceResponse* response,
65 IPC::Sender* sender) OVERRIDE;
67 void RemovePendingThrottleOnIoThread(IoThreadClientThrottle* throttle);
69 static void OnIoThreadClientReady(int new_render_process_id,
70 int new_render_frame_id);
71 static void AddPendingThrottle(int render_process_id,
73 IoThreadClientThrottle* pending_throttle);
75 friend struct base::DefaultLazyInstanceTraits<
76 RuntimeResourceDispatcherHostDelegateAndroid>;
77 // These methods must be called on IO thread.
78 void OnIoThreadClientReadyInternal(int new_render_process_id,
79 int new_render_frame_id);
80 void AddPendingThrottleOnIoThread(int render_process_id,
82 IoThreadClientThrottle* pending_throttle);
84 typedef std::pair<int, int> FrameRouteIDPair;
85 typedef std::map<FrameRouteIDPair, IoThreadClientThrottle*>
88 // Only accessed on the IO thread.
89 PendingThrottleMap pending_throttles_;
91 DISALLOW_COPY_AND_ASSIGN(RuntimeResourceDispatcherHostDelegateAndroid);
96 #endif // XWALK_RUNTIME_BROWSER_RUNTIME_RESOURCE_DISPATCHER_HOST_DELEGATE_ANDROID_H_