| 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 CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "chrome/common/metrics/variation_ids.h" | 14 #include "chrome/common/metrics/variation_ids.h" |
| 15 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 15 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 16 | 16 |
| 17 class DelayedResourceQueue; | 17 class DelayedResourceQueue; |
| 18 class DownloadRequestLimiter; | 18 class DownloadRequestLimiter; |
| 19 class SafeBrowsingService; | 19 class SafeBrowsingService; |
| 20 class UserScriptListener; | 20 class UserScriptListener; |
| 21 | 21 |
| 22 namespace prerender { | 22 namespace prerender { |
| 23 class PrerenderTracker; | 23 class PrerenderRenderViewTracker; |
| 24 } | 24 } |
| 25 | 25 |
| 26 // Implements ResourceDispatcherHostDelegate. Currently used by the Prerender | 26 // Implements ResourceDispatcherHostDelegate. Currently used by the Prerender |
| 27 // system to abort requests and add to the load flags when a request begins. | 27 // system to abort requests and add to the load flags when a request begins. |
| 28 class ChromeResourceDispatcherHostDelegate | 28 class ChromeResourceDispatcherHostDelegate |
| 29 : public content::ResourceDispatcherHostDelegate, | 29 : public content::ResourceDispatcherHostDelegate, |
| 30 public base::FieldTrialList::Observer { | 30 public base::FieldTrialList::Observer { |
| 31 public: | 31 public: |
| 32 // This class does not take ownership of the tracker but merely holds a | 32 // This class does not take ownership of the tracker but merely holds a |
| 33 // reference to it to avoid accessing g_browser_process. | 33 // reference to it to avoid accessing g_browser_process. |
| 34 // |prerender_tracker| must outlive |this|. | 34 // |prerender_render_view_tracker| must outlive |this|. |
| 35 explicit ChromeResourceDispatcherHostDelegate( | 35 explicit ChromeResourceDispatcherHostDelegate( |
| 36 prerender::PrerenderTracker* prerender_tracker); | 36 prerender::PrerenderRenderViewTracker* prerender_render_view_tracker); |
| 37 virtual ~ChromeResourceDispatcherHostDelegate(); | 37 virtual ~ChromeResourceDispatcherHostDelegate(); |
| 38 | 38 |
| 39 // ResourceDispatcherHostDelegate implementation. | 39 // ResourceDispatcherHostDelegate implementation. |
| 40 virtual bool ShouldBeginRequest( | 40 virtual bool ShouldBeginRequest( |
| 41 int child_id, | 41 int child_id, |
| 42 int route_id, | 42 int route_id, |
| 43 const std::string& method, | 43 const std::string& method, |
| 44 const GURL& url, | 44 const GURL& url, |
| 45 ResourceType::Type resource_type, | 45 ResourceType::Type resource_type, |
| 46 content::ResourceContext* resource_context, | 46 content::ResourceContext* resource_context, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // new variation IDs. | 110 // new variation IDs. |
| 111 void InitVariationIDsCacheIfNeeded(); | 111 void InitVariationIDsCacheIfNeeded(); |
| 112 | 112 |
| 113 // Takes whatever is currently in |variation_ids_set_| and recreates | 113 // Takes whatever is currently in |variation_ids_set_| and recreates |
| 114 // |variation_ids_header_| with it. | 114 // |variation_ids_header_| with it. |
| 115 void UpdateVariationIDsHeaderValue(); | 115 void UpdateVariationIDsHeaderValue(); |
| 116 | 116 |
| 117 scoped_refptr<DownloadRequestLimiter> download_request_limiter_; | 117 scoped_refptr<DownloadRequestLimiter> download_request_limiter_; |
| 118 scoped_refptr<SafeBrowsingService> safe_browsing_; | 118 scoped_refptr<SafeBrowsingService> safe_browsing_; |
| 119 scoped_refptr<UserScriptListener> user_script_listener_; | 119 scoped_refptr<UserScriptListener> user_script_listener_; |
| 120 prerender::PrerenderTracker* prerender_tracker_; | 120 prerender::PrerenderRenderViewTracker* prerender_render_view_tracker_; |
| 121 | 121 |
| 122 // Whether or not we've initialized the Cache. | 122 // Whether or not we've initialized the Cache. |
| 123 bool variation_ids_cache_initialized_; | 123 bool variation_ids_cache_initialized_; |
| 124 | 124 |
| 125 // Keep a cache of variation IDs that are transmitted in headers to Google. | 125 // Keep a cache of variation IDs that are transmitted in headers to Google. |
| 126 // This consists of a list of valid IDs, and the actual transmitted header. | 126 // This consists of a list of valid IDs, and the actual transmitted header. |
| 127 // Note that since this cache is both initialized and accessed from the IO | 127 // Note that since this cache is both initialized and accessed from the IO |
| 128 // thread, we do not need to synchronize its uses. | 128 // thread, we do not need to synchronize its uses. |
| 129 std::set<chrome_variations::ID> variation_ids_set_; | 129 std::set<chrome_variations::ID> variation_ids_set_; |
| 130 std::string variation_ids_header_; | 130 std::string variation_ids_header_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(ChromeResourceDispatcherHostDelegate); | 132 DISALLOW_COPY_AND_ASSIGN(ChromeResourceDispatcherHostDelegate); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 #endif // CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE
_H_ | 135 #endif // CHROME_BROWSER_RENDERER_HOST_CHROME_RESOURCE_DISPATCHER_HOST_DELEGATE
_H_ |
| OLD | NEW |