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

Side by Side Diff: chrome/browser/component_updater/component_updater_resource_throttle.cc

Issue 893843003: Add RedirectInfo as a redirect parameter to ResourceThrottles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Document ResourceThrottle Created 5 years, 10 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
OLDNEW
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 #include "chrome/browser/component_updater/component_updater_resource_throttle.h " 5 #include "chrome/browser/component_updater/component_updater_resource_throttle.h "
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "components/component_updater/component_updater_service.h" 9 #include "components/component_updater/component_updater_service.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 14 matching lines...) Expand all
25 // The lifetime is controlled by Chrome's resource loader so the component 25 // The lifetime is controlled by Chrome's resource loader so the component
26 // updater cannot touch objects from this class except via weak pointers. 26 // updater cannot touch objects from this class except via weak pointers.
27 class CUResourceThrottle : public content::ResourceThrottle, 27 class CUResourceThrottle : public content::ResourceThrottle,
28 public base::SupportsWeakPtr<CUResourceThrottle> { 28 public base::SupportsWeakPtr<CUResourceThrottle> {
29 public: 29 public:
30 CUResourceThrottle(); 30 CUResourceThrottle();
31 ~CUResourceThrottle() override; 31 ~CUResourceThrottle() override;
32 32
33 // Overriden from ResourceThrottle. 33 // Overriden from ResourceThrottle.
34 void WillStartRequest(bool* defer) override; 34 void WillStartRequest(bool* defer) override;
35 void WillRedirectRequest(const GURL& new_url, bool* defer) override; 35 void WillRedirectRequest(const net::RedirectInfo& redirect_info,
36 bool* defer) override;
36 const char* GetNameForLogging() const override; 37 const char* GetNameForLogging() const override;
37 38
38 // Component updater calls this function via PostTask to unblock the request. 39 // Component updater calls this function via PostTask to unblock the request.
39 void Unblock(); 40 void Unblock();
40 41
41 typedef std::vector<base::WeakPtr<CUResourceThrottle> > WeakPtrVector; 42 typedef std::vector<base::WeakPtr<CUResourceThrottle> > WeakPtrVector;
42 43
43 private: 44 private:
44 enum State { NEW, BLOCKED, UNBLOCKED }; 45 enum State { NEW, BLOCKED, UNBLOCKED };
45 46
(...skipping 10 matching lines...) Expand all
56 57
57 void CUResourceThrottle::WillStartRequest(bool* defer) { 58 void CUResourceThrottle::WillStartRequest(bool* defer) {
58 if (state_ != UNBLOCKED) { 59 if (state_ != UNBLOCKED) {
59 state_ = BLOCKED; 60 state_ = BLOCKED;
60 *defer = true; 61 *defer = true;
61 } else { 62 } else {
62 *defer = false; 63 *defer = false;
63 } 64 }
64 } 65 }
65 66
66 void CUResourceThrottle::WillRedirectRequest(const GURL& new_url, bool* defer) { 67 void CUResourceThrottle::WillRedirectRequest(
68 const net::RedirectInfo& redirect_info, bool* defer) {
67 WillStartRequest(defer); 69 WillStartRequest(defer);
68 } 70 }
69 71
70 const char* CUResourceThrottle::GetNameForLogging() const { 72 const char* CUResourceThrottle::GetNameForLogging() const {
71 return "ComponentUpdateResourceThrottle"; 73 return "ComponentUpdateResourceThrottle";
72 } 74 }
73 75
74 void CUResourceThrottle::Unblock() { 76 void CUResourceThrottle::Unblock() {
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
76 if (state_ == BLOCKED) 78 if (state_ == BLOCKED)
(...skipping 22 matching lines...) Expand all
99 BrowserThread::UI, 101 BrowserThread::UI,
100 FROM_HERE, 102 FROM_HERE,
101 base::Bind(&ComponentUpdateService::MaybeThrottle, 103 base::Bind(&ComponentUpdateService::MaybeThrottle,
102 base::Unretained(cus), 104 base::Unretained(cus),
103 crx_id, 105 crx_id,
104 base::Bind(&UnblockThrottleOnUIThread, rt->AsWeakPtr()))); 106 base::Bind(&UnblockThrottleOnUIThread, rt->AsWeakPtr())));
105 return rt; 107 return rt;
106 } 108 }
107 109
108 } // namespace component_updater 110 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698