Fix race condition in gyp/ninja builds.
[chromium-blink-merge.git] / android_webview / browser / renderer_host / aw_resource_dispatcher_host_delegate.h
blob55e61c862ae79eaa493a6ddecd7310a60a5da6a3
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_
8 #include <map>
10 #include "base/lazy_instance.h"
11 #include "content/public/browser/resource_dispatcher_host_delegate.h"
13 namespace content {
14 class ResourceDispatcherHostLoginDelegate;
15 struct ResourceResponse;
16 } // namespace content
18 namespace IPC {
19 class Sender;
20 } // namespace IPC
22 namespace android_webview {
24 class IoThreadClientThrottle;
26 class AwResourceDispatcherHostDelegate
27 : public content::ResourceDispatcherHostDelegate {
28 public:
29 static void ResourceDispatcherHostCreated();
31 // Overriden methods from ResourceDispatcherHostDelegate.
32 virtual void RequestBeginning(
33 net::URLRequest* request,
34 content::ResourceContext* resource_context,
35 content::AppCacheService* appcache_service,
36 content::ResourceType::Type resource_type,
37 int child_id,
38 int route_id,
39 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
40 virtual void DownloadStarting(
41 net::URLRequest* request,
42 content::ResourceContext* resource_context,
43 int child_id,
44 int route_id,
45 int request_id,
46 bool is_content_initiated,
47 bool must_download,
48 ScopedVector<content::ResourceThrottle>* throttles) OVERRIDE;
49 virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
50 net::AuthChallengeInfo* auth_info,
51 net::URLRequest* request) OVERRIDE;
52 virtual bool HandleExternalProtocol(const GURL& url,
53 int child_id,
54 int route_id,
55 bool initiated_by_user_gesture) OVERRIDE;
56 virtual void OnResponseStarted(
57 net::URLRequest* request,
58 content::ResourceContext* resource_context,
59 content::ResourceResponse* response,
60 IPC::Sender* sender) OVERRIDE;
62 virtual void OnRequestRedirected(
63 const GURL& redirect_url,
64 net::URLRequest* request,
65 content::ResourceContext* resource_context,
66 content::ResourceResponse* response) OVERRIDE;
68 void RemovePendingThrottleOnIoThread(IoThreadClientThrottle* throttle);
70 static void OnIoThreadClientReady(int new_render_process_id,
71 int new_render_frame_id);
72 static void AddPendingThrottle(int render_process_id,
73 int render_frame_id,
74 IoThreadClientThrottle* pending_throttle);
76 private:
77 friend struct base::DefaultLazyInstanceTraits<
78 AwResourceDispatcherHostDelegate>;
79 AwResourceDispatcherHostDelegate();
80 virtual ~AwResourceDispatcherHostDelegate();
82 // These methods must be called on IO thread.
83 void OnIoThreadClientReadyInternal(int new_render_process_id,
84 int new_render_frame_id);
85 void AddPendingThrottleOnIoThread(int render_process_id,
86 int render_frame_id,
87 IoThreadClientThrottle* pending_throttle);
88 void AddExtraHeadersIfNeeded(net::URLRequest* request,
89 content::ResourceContext* resource_context);
91 // Pair of render_process_id and render_frame_id.
92 typedef std::pair<int, int> FrameRouteIDPair;
93 typedef std::map<FrameRouteIDPair, IoThreadClientThrottle*>
94 PendingThrottleMap;
96 // Only accessed on the IO thread.
97 PendingThrottleMap pending_throttles_;
99 DISALLOW_COPY_AND_ASSIGN(AwResourceDispatcherHostDelegate);
102 } // namespace android_webview
104 #endif // ANDROID_WEBVIEW_LIB_RENDERER_HOST_AW_RESOURCE_DISPATCHER_HOST_H_