OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "content/browser/media/webrtc_identity_store.h" | 5 #include "content/browser/media/webrtc_identity_store.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 // The class represents an identity request which calls back to the external | 131 // The class represents an identity request which calls back to the external |
132 // client when the request completes. | 132 // client when the request completes. |
133 // Its lifetime is tied with the Callback held by the corresponding | 133 // Its lifetime is tied with the Callback held by the corresponding |
134 // WebRTCIdentityRequest. | 134 // WebRTCIdentityRequest. |
135 class WebRTCIdentityRequestHandle { | 135 class WebRTCIdentityRequestHandle { |
136 public: | 136 public: |
137 WebRTCIdentityRequestHandle( | 137 WebRTCIdentityRequestHandle( |
138 WebRTCIdentityStore* store, | 138 WebRTCIdentityStore* store, |
139 const WebRTCIdentityStore::CompletionCallback& callback) | 139 const WebRTCIdentityStore::CompletionCallback& callback) |
140 : store_(store), request_(NULL), callback_(callback) {} | 140 : request_(NULL), callback_(callback) {} |
141 | 141 |
142 private: | 142 private: |
143 friend class WebRTCIdentityStore; | 143 friend class WebRTCIdentityStore; |
144 | 144 |
145 // Cancel the request. Does nothing if the request finished or was already | 145 // Cancel the request. Does nothing if the request finished or was already |
146 // cancelled. | 146 // cancelled. |
147 void Cancel() { | 147 void Cancel() { |
148 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 148 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
149 if (!request_) | 149 if (!request_) |
150 return; | 150 return; |
(...skipping 14 matching lines...) Expand all Loading... |
165 | 165 |
166 void OnRequestComplete(int error, | 166 void OnRequestComplete(int error, |
167 const std::string& certificate, | 167 const std::string& certificate, |
168 const std::string& private_key) { | 168 const std::string& private_key) { |
169 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 169 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
170 DCHECK(request_); | 170 DCHECK(request_); |
171 request_ = NULL; | 171 request_ = NULL; |
172 base::ResetAndReturn(&callback_).Run(error, certificate, private_key); | 172 base::ResetAndReturn(&callback_).Run(error, certificate, private_key); |
173 } | 173 } |
174 | 174 |
175 WebRTCIdentityStore* store_; | |
176 WebRTCIdentityRequest* request_; | 175 WebRTCIdentityRequest* request_; |
177 WebRTCIdentityStore::CompletionCallback callback_; | 176 WebRTCIdentityStore::CompletionCallback callback_; |
178 | 177 |
179 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityRequestHandle); | 178 DISALLOW_COPY_AND_ASSIGN(WebRTCIdentityRequestHandle); |
180 }; | 179 }; |
181 | 180 |
182 WebRTCIdentityStore::WebRTCIdentityStore(const base::FilePath& path, | 181 WebRTCIdentityStore::WebRTCIdentityStore(const base::FilePath& path, |
183 storage::SpecialStoragePolicy* policy) | 182 storage::SpecialStoragePolicy* policy) |
184 : validity_period_(base::TimeDelta::FromDays(30)), | 183 : validity_period_(base::TimeDelta::FromDays(30)), |
185 task_runner_(base::WorkerPool::GetTaskRunner(true)), | 184 task_runner_(base::WorkerPool::GetTaskRunner(true)), |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 validity_period_, result), | 316 validity_period_, result), |
318 base::Bind(&WebRTCIdentityStore::GenerateIdentityCallback, this, | 317 base::Bind(&WebRTCIdentityStore::GenerateIdentityCallback, this, |
319 request, base::Owned(result)))) { | 318 request, base::Owned(result)))) { |
320 // Completes the request with error if failed to post the task. | 319 // Completes the request with error if failed to post the task. |
321 WebRTCIdentityRequestResult result(net::ERR_UNEXPECTED, "", ""); | 320 WebRTCIdentityRequestResult result(net::ERR_UNEXPECTED, "", ""); |
322 PostRequestResult(request, result); | 321 PostRequestResult(request, result); |
323 } | 322 } |
324 } | 323 } |
325 | 324 |
326 } // namespace content | 325 } // namespace content |
OLD | NEW |