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 "extensions/browser/content_hash_fetcher.h" | 5 #include "extensions/browser/content_hash_fetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 cancelled_(false) { | 193 cancelled_(false) { |
194 bool got_id = | 194 bool got_id = |
195 content::BrowserThread::GetCurrentThreadIdentifier(&creation_thread_); | 195 content::BrowserThread::GetCurrentThreadIdentifier(&creation_thread_); |
196 DCHECK(got_id); | 196 DCHECK(got_id); |
197 } | 197 } |
198 | 198 |
199 void ContentHashFetcherJob::Start() { | 199 void ContentHashFetcherJob::Start() { |
200 base::FilePath verified_contents_path = | 200 base::FilePath verified_contents_path = |
201 file_util::GetVerifiedContentsPath(extension_path_); | 201 file_util::GetVerifiedContentsPath(extension_path_); |
202 base::PostTaskWithTraitsAndReplyWithResult( | 202 base::PostTaskWithTraitsAndReplyWithResult( |
203 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 203 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
204 base::TaskPriority::USER_VISIBLE), | |
205 base::Bind(&ContentHashFetcherJob::LoadVerifiedContents, this, | 204 base::Bind(&ContentHashFetcherJob::LoadVerifiedContents, this, |
206 verified_contents_path), | 205 verified_contents_path), |
207 base::Bind(&ContentHashFetcherJob::DoneCheckingForVerifiedContents, | 206 base::Bind(&ContentHashFetcherJob::DoneCheckingForVerifiedContents, |
208 this)); | 207 this)); |
209 } | 208 } |
210 | 209 |
211 void ContentHashFetcherJob::Cancel() { | 210 void ContentHashFetcherJob::Cancel() { |
212 base::AutoLock autolock(cancelled_lock_); | 211 base::AutoLock autolock(cancelled_lock_); |
213 cancelled_ = true; | 212 cancelled_ = true; |
214 } | 213 } |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 // move to parsing this in a sandboxed helper (crbug.com/372878). | 318 // move to parsing this in a sandboxed helper (crbug.com/372878). |
320 std::unique_ptr<base::Value> parsed(base::JSONReader::Read(*response)); | 319 std::unique_ptr<base::Value> parsed(base::JSONReader::Read(*response)); |
321 if (parsed) { | 320 if (parsed) { |
322 VLOG(1) << "JSON parsed ok for " << extension_id_; | 321 VLOG(1) << "JSON parsed ok for " << extension_id_; |
323 | 322 |
324 parsed.reset(); // no longer needed | 323 parsed.reset(); // no longer needed |
325 base::FilePath destination = | 324 base::FilePath destination = |
326 file_util::GetVerifiedContentsPath(extension_path_); | 325 file_util::GetVerifiedContentsPath(extension_path_); |
327 size_t size = response->size(); | 326 size_t size = response->size(); |
328 base::PostTaskWithTraitsAndReplyWithResult( | 327 base::PostTaskWithTraitsAndReplyWithResult( |
329 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 328 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
330 base::TaskPriority::USER_VISIBLE), | |
331 base::Bind(&WriteFileHelper, destination, base::Passed(&response)), | 329 base::Bind(&WriteFileHelper, destination, base::Passed(&response)), |
332 base::Bind(&ContentHashFetcherJob::OnVerifiedContentsWritten, this, | 330 base::Bind(&ContentHashFetcherJob::OnVerifiedContentsWritten, this, |
333 size)); | 331 size)); |
334 } else { | 332 } else { |
335 DoneFetchingVerifiedContents(false); | 333 DoneFetchingVerifiedContents(false); |
336 } | 334 } |
337 } | 335 } |
338 | 336 |
339 void ContentHashFetcherJob::OnVerifiedContentsWritten(size_t expected_size, | 337 void ContentHashFetcherJob::OnVerifiedContentsWritten(size_t expected_size, |
340 int write_result) { | 338 int write_result) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 536 |
539 for (JobMap::iterator i = jobs_.begin(); i != jobs_.end(); ++i) { | 537 for (JobMap::iterator i = jobs_.begin(); i != jobs_.end(); ++i) { |
540 if (i->second.get() == job.get()) { | 538 if (i->second.get() == job.get()) { |
541 jobs_.erase(i); | 539 jobs_.erase(i); |
542 break; | 540 break; |
543 } | 541 } |
544 } | 542 } |
545 } | 543 } |
546 | 544 |
547 } // namespace extensions | 545 } // namespace extensions |
OLD | NEW |