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 #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" |
11 #include "content/public/browser/resource_controller.h" | |
12 #include "content/public/browser/resource_throttle.h" | 11 #include "content/public/browser/resource_throttle.h" |
13 | 12 |
14 using content::BrowserThread; | 13 using content::BrowserThread; |
15 | 14 |
16 namespace component_updater { | 15 namespace component_updater { |
17 | 16 |
18 namespace { | 17 namespace { |
19 | 18 |
20 /////////////////////////////////////////////////////////////////////////////// | 19 /////////////////////////////////////////////////////////////////////////////// |
21 // In charge of blocking url requests until the |crx_id| component has been | 20 // In charge of blocking url requests until the |crx_id| component has been |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 WillStartRequest(defer); | 68 WillStartRequest(defer); |
70 } | 69 } |
71 | 70 |
72 const char* CUResourceThrottle::GetNameForLogging() const { | 71 const char* CUResourceThrottle::GetNameForLogging() const { |
73 return "ComponentUpdateResourceThrottle"; | 72 return "ComponentUpdateResourceThrottle"; |
74 } | 73 } |
75 | 74 |
76 void CUResourceThrottle::Unblock() { | 75 void CUResourceThrottle::Unblock() { |
77 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 76 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
78 if (state_ == BLOCKED) | 77 if (state_ == BLOCKED) |
79 controller()->Resume(); | 78 Resume(); |
80 state_ = UNBLOCKED; | 79 state_ = UNBLOCKED; |
81 } | 80 } |
82 | 81 |
83 void UnblockThrottleOnUIThread(base::WeakPtr<CUResourceThrottle> rt) { | 82 void UnblockThrottleOnUIThread(base::WeakPtr<CUResourceThrottle> rt) { |
84 BrowserThread::PostTask(BrowserThread::IO, | 83 BrowserThread::PostTask(BrowserThread::IO, |
85 FROM_HERE, | 84 FROM_HERE, |
86 base::Bind(&CUResourceThrottle::Unblock, rt)); | 85 base::Bind(&CUResourceThrottle::Unblock, rt)); |
87 } | 86 } |
88 | 87 |
89 } // namespace | 88 } // namespace |
(...skipping 11 matching lines...) Expand all Loading... |
101 BrowserThread::UI, | 100 BrowserThread::UI, |
102 FROM_HERE, | 101 FROM_HERE, |
103 base::Bind(&ComponentUpdateService::MaybeThrottle, | 102 base::Bind(&ComponentUpdateService::MaybeThrottle, |
104 base::Unretained(cus), | 103 base::Unretained(cus), |
105 crx_id, | 104 crx_id, |
106 base::Bind(&UnblockThrottleOnUIThread, rt->AsWeakPtr()))); | 105 base::Bind(&UnblockThrottleOnUIThread, rt->AsWeakPtr()))); |
107 return rt; | 106 return rt; |
108 } | 107 } |
109 | 108 |
110 } // namespace component_updater | 109 } // namespace component_updater |
OLD | NEW |