Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: chrome/browser/chromeos/login/merge_session_throttle.h

Issue 23678007: OAuth2LoginManager+MergeSessionThrottle hardening, multi-profle support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_MERGE_SESSION_THROTTLE_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MERGE_SESSION_THROTTLE_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MERGE_SESSION_THROTTLE_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MERGE_SESSION_THROTTLE_H_
7 7
8 #include <set>
9
10 #include "base/atomic_ref_count.h"
8 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/chromeos/login/merge_session_load_page.h" 13 #include "chrome/browser/chromeos/login/merge_session_load_page.h"
11 #include "content/public/browser/resource_throttle.h" 14 #include "content/public/browser/resource_throttle.h"
12 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
13 16
17 class Profile;
18
14 namespace net { 19 namespace net {
15 class URLRequest; 20 class URLRequest;
16 } 21 }
17 22
23 namespace chromeos {
24 class OAuth2LoginManager;
25 }
26
18 // Used to show an interstitial page while merge session process (cookie 27 // Used to show an interstitial page while merge session process (cookie
19 // reconstruction from OAuth2 refresh token in ChromeOS login) is still in 28 // reconstruction from OAuth2 refresh token in ChromeOS login) is still in
20 // progress while we are attempting to load a google property. 29 // progress while we are attempting to load a google property.
21 class MergeSessionThrottle 30 class MergeSessionThrottle
22 : public content::ResourceThrottle, 31 : public content::ResourceThrottle,
23 public base::SupportsWeakPtr<MergeSessionThrottle> { 32 public base::SupportsWeakPtr<MergeSessionThrottle> {
24 public: 33 public:
25 explicit MergeSessionThrottle(net::URLRequest* request); 34 explicit MergeSessionThrottle(net::URLRequest* request);
26 virtual ~MergeSessionThrottle(); 35 virtual ~MergeSessionThrottle();
27 36
28 // content::ResourceThrottle implementation: 37 // content::ResourceThrottle implementation:
29 virtual void WillStartRequest(bool* defer) OVERRIDE; 38 virtual void WillStartRequest(bool* defer) OVERRIDE;
30 39
40 // Checks if session is already merged.
41 static bool AreAllSessionMergedAlready();
42
31 private: 43 private:
44
32 // MergeSessionLoadPage callback. 45 // MergeSessionLoadPage callback.
33 void OnBlockingPageComplete(); 46 void OnBlockingPageComplete();
34 47
35 // Erase the state associated with a deferred load request. 48 // Erase the state associated with a deferred load request.
36 void ClearRequestInfo(); 49 void ClearRequestInfo();
37 bool IsRemote(const GURL& url) const; 50 bool IsRemote(const GURL& url) const;
38 51
39 // True if we should show the merge session in progress page. 52 // True if we should show the merge session in progress page. The function
53 // is safe to be called on any thread.
40 bool ShouldShowMergeSessionPage(const GURL& url) const; 54 bool ShouldShowMergeSessionPage(const GURL& url) const;
41 55
56 // Adds/removes |profile| to/from the blocking profiles set.
57 static void BlockProfile(Profile* profile);
58 static void UnblockProfile(Profile* profile);
59
60 // Helper method that checks if we should show interstitial page based on
61 // the state of the Profile that's derived from |render_process_id| and
62 // |render_view_id|.
63 static bool ShouldShowInterstitialPage(int render_process_id,
64 int render_view_id);
65
66 // Tests merge session status and if needed shows interstitial page.
67 // The function must be called from UI thread.
68 static void ShowDeleayedLoadingPageOnUIThread(
69 int render_process_id,
70 int render_view_id,
71 const GURL& url,
72 const chromeos::MergeSessionLoadPage::CompletionCallback& callback);
73
42 net::URLRequest* request_; 74 net::URLRequest* request_;
43 75
76 // Global counter that keeps the track of session merge status for all
77 // encountered profiles. This is used to determine if a throttle should
78 // even be even added to new requests. Value of 0 (initial) means that we
79 // probably have some profiles to restore, while 1 means that all known
80 // profiles are restored.
81 static base::AtomicRefCount all_profiles_restored_;
82
44 DISALLOW_COPY_AND_ASSIGN(MergeSessionThrottle); 83 DISALLOW_COPY_AND_ASSIGN(MergeSessionThrottle);
45 }; 84 };
46 85
47 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MERGE_SESSION_THROTTLE_H_ 86 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MERGE_SESSION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698