OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMEOS_LOGIN_SIGNIN_MERGE_SESSION_THROTTLE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_MERGE_SESSION_THROTTLE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_MERGE_SESSION_THROTTLE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_MERGE_SESSION_THROTTLE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/atomic_ref_count.h" | 10 #include "base/atomic_ref_count.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // progress while we are attempting to load a google property. | 29 // progress while we are attempting to load a google property. |
30 class MergeSessionThrottle | 30 class MergeSessionThrottle |
31 : public content::ResourceThrottle, | 31 : public content::ResourceThrottle, |
32 public base::SupportsWeakPtr<MergeSessionThrottle> { | 32 public base::SupportsWeakPtr<MergeSessionThrottle> { |
33 public: | 33 public: |
34 // Passed a boolean indicating whether or not it is OK to proceed with the | 34 // Passed a boolean indicating whether or not it is OK to proceed with the |
35 // page load. | 35 // page load. |
36 typedef base::Closure CompletionCallback; | 36 typedef base::Closure CompletionCallback; |
37 | 37 |
38 explicit MergeSessionThrottle(net::URLRequest* request, | 38 explicit MergeSessionThrottle(net::URLRequest* request, |
39 content::ResourceType::Type resource_type); | 39 content::ResourceType resource_type); |
40 virtual ~MergeSessionThrottle(); | 40 virtual ~MergeSessionThrottle(); |
41 | 41 |
42 // content::ResourceThrottle implementation: | 42 // content::ResourceThrottle implementation: |
43 virtual void WillStartRequest(bool* defer) OVERRIDE; | 43 virtual void WillStartRequest(bool* defer) OVERRIDE; |
44 virtual const char* GetNameForLogging() const OVERRIDE; | 44 virtual const char* GetNameForLogging() const OVERRIDE; |
45 | 45 |
46 // Checks if session is already merged. | 46 // Checks if session is already merged. |
47 static bool AreAllSessionMergedAlready(); | 47 static bool AreAllSessionMergedAlready(); |
48 | 48 |
49 private: | 49 private: |
(...skipping 13 matching lines...) Expand all Loading... |
63 static void BlockProfile(Profile* profile); | 63 static void BlockProfile(Profile* profile); |
64 static void UnblockProfile(Profile* profile); | 64 static void UnblockProfile(Profile* profile); |
65 | 65 |
66 // Helper method that checks if we should delay reasource loading based on | 66 // Helper method that checks if we should delay reasource loading based on |
67 // the state of the Profile that's derived from |render_process_id| and | 67 // the state of the Profile that's derived from |render_process_id| and |
68 // |render_view_id|. | 68 // |render_view_id|. |
69 static bool ShouldDelayRequest(int render_process_id, | 69 static bool ShouldDelayRequest(int render_process_id, |
70 int render_view_id); | 70 int render_view_id); |
71 | 71 |
72 // Tests merge session status and if needed generates request | 72 // Tests merge session status and if needed generates request |
73 // waiter (for ResourceType::XHR content) or shows interstitial page | 73 // waiter (for content::RESOURCE_TYPE_XHR content) or shows interstitial page |
74 // (for ResourceType::MAIN_FRAME). | 74 // (for content::RESOURCE_TYPE_MAIN_FRAME). |
75 // The function must be called from UI thread. | 75 // The function must be called from UI thread. |
76 static void DeleayResourceLoadingOnUIThread( | 76 static void DeleayResourceLoadingOnUIThread( |
77 content::ResourceType::Type resource_type, | 77 content::ResourceType resource_type, |
78 int render_process_id, | 78 int render_process_id, |
79 int render_view_id, | 79 int render_view_id, |
80 const GURL& url, | 80 const GURL& url, |
81 const MergeSessionThrottle::CompletionCallback& callback); | 81 const MergeSessionThrottle::CompletionCallback& callback); |
82 | 82 |
83 net::URLRequest* request_; | 83 net::URLRequest* request_; |
84 content::ResourceType::Type resource_type_; | 84 content::ResourceType resource_type_; |
85 | 85 |
86 // Global counter that keeps the track of session merge status for all | 86 // Global counter that keeps the track of session merge status for all |
87 // encountered profiles. This is used to determine if a throttle should | 87 // encountered profiles. This is used to determine if a throttle should |
88 // even be even added to new requests. Value of 0 (initial) means that we | 88 // even be even added to new requests. Value of 0 (initial) means that we |
89 // probably have some profiles to restore, while 1 means that all known | 89 // probably have some profiles to restore, while 1 means that all known |
90 // profiles are restored. | 90 // profiles are restored. |
91 static base::AtomicRefCount all_profiles_restored_; | 91 static base::AtomicRefCount all_profiles_restored_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(MergeSessionThrottle); | 93 DISALLOW_COPY_AND_ASSIGN(MergeSessionThrottle); |
94 }; | 94 }; |
95 | 95 |
96 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_MERGE_SESSION_THROTTLE_H_ | 96 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_MERGE_SESSION_THROTTLE_H_ |
OLD | NEW |