Upstream version 11.39.244.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / runtime_resource_dispatcher_host_delegate_android.h
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.
4
5 #ifndef XWALK_RUNTIME_BROWSER_RUNTIME_RESOURCE_DISPATCHER_HOST_DELEGATE_ANDROID_H_
6 #define XWALK_RUNTIME_BROWSER_RUNTIME_RESOURCE_DISPATCHER_HOST_DELEGATE_ANDROID_H_
7
8 #include <map>
9 #include <utility>
10
11 #include "content/public/browser/content_browser_client.h"
12 #include "xwalk/runtime/browser/runtime_resource_dispatcher_host_delegate.h"
13
14 namespace content {
15 class ResourceDispatcherHostLoginDelegate;
16 struct ResourceResponse;
17 }  // namespace content
18
19 namespace IPC {
20 class Sender;
21 }  // namespace IPC
22
23 namespace xwalk {
24
25 class IoThreadClientThrottle;
26
27 class RuntimeResourceDispatcherHostDelegateAndroid
28     : public RuntimeResourceDispatcherHostDelegate {
29  public:
30   RuntimeResourceDispatcherHostDelegateAndroid();
31   virtual ~RuntimeResourceDispatcherHostDelegateAndroid();
32
33   virtual void RequestBeginning(
34       net::URLRequest* request,
35       content::ResourceContext* resource_context,
36       content::AppCacheService* appcache_service,
37       content::ResourceType resource_type,
38       ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
39   virtual void DownloadStarting(
40       net::URLRequest* request,
41       content::ResourceContext* resource_context,
42       int child_id,
43       int route_id,
44       int request_id,
45       bool is_content_initiated,
46       bool must_download,
47       ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
48   virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
49       net::AuthChallengeInfo* auth_info,
50       net::URLRequest* request) OVERRIDE;
51   virtual bool HandleExternalProtocol(
52       const GURL& url,
53       int child_id,
54       int route_id) OVERRIDE;
55   virtual void OnResponseStarted(
56       net::URLRequest* request,
57       content::ResourceContext* resource_context,
58       content::ResourceResponse* response,
59       IPC::Sender* sender) OVERRIDE;
60
61   void RemovePendingThrottleOnIoThread(IoThreadClientThrottle* throttle);
62
63   static void OnIoThreadClientReady(int new_render_process_id,
64                                     int new_render_frame_id);
65   static void AddPendingThrottle(int render_process_id,
66                                  int render_frame_id,
67                                  IoThreadClientThrottle* pending_throttle);
68  private:
69   // These methods must be called on IO thread.
70   void OnIoThreadClientReadyInternal(int new_render_process_id,
71                                      int new_render_frame_id);
72   void AddPendingThrottleOnIoThread(int render_process_id,
73                                     int render_frame_id,
74                                     IoThreadClientThrottle* pending_throttle);
75
76   typedef std::pair<int, int> FrameRouteIDPair;
77   typedef std::map<FrameRouteIDPair, IoThreadClientThrottle*>
78       PendingThrottleMap;
79
80   // Only accessed on the IO thread.
81   PendingThrottleMap pending_throttles_;
82
83   DISALLOW_COPY_AND_ASSIGN(RuntimeResourceDispatcherHostDelegateAndroid);
84 };
85
86 }  // namespace xwalk
87
88 #endif  // XWALK_RUNTIME_BROWSER_RUNTIME_RESOURCE_DISPATCHER_HOST_DELEGATE_ANDROID_H_