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 | 10 |
11 #include "base/base64.h" | 11 #include "base/base64.h" |
12 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/json/json_reader.h" | 14 #include "base/json/json_reader.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "base/task_runner_util.h" | 19 #include "base/task_runner_util.h" |
20 #include "base/timer/elapsed_timer.h" | 20 #include "base/timer/elapsed_timer.h" |
21 #include "base/version.h" | 21 #include "base/version.h" |
22 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/storage_partition.h" |
24 #include "crypto/sha2.h" | 25 #include "crypto/sha2.h" |
25 #include "extensions/browser/computed_hashes.h" | 26 #include "extensions/browser/computed_hashes.h" |
26 #include "extensions/browser/content_hash_tree.h" | 27 #include "extensions/browser/content_hash_tree.h" |
27 #include "extensions/browser/content_verifier_delegate.h" | 28 #include "extensions/browser/content_verifier_delegate.h" |
28 #include "extensions/browser/verified_contents.h" | 29 #include "extensions/browser/verified_contents.h" |
29 #include "extensions/common/constants.h" | 30 #include "extensions/common/constants.h" |
30 #include "extensions/common/extension.h" | 31 #include "extensions/common/extension.h" |
31 #include "extensions/common/file_util.h" | 32 #include "extensions/common/file_util.h" |
32 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
33 #include "net/url_request/url_fetcher.h" | 34 #include "net/url_request/url_fetcher.h" |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 | 456 |
456 // TODO(asargent) - we should do something here to remember recent attempts | 457 // TODO(asargent) - we should do something here to remember recent attempts |
457 // to fetch signatures by extension id, and use exponential backoff to avoid | 458 // to fetch signatures by extension id, and use exponential backoff to avoid |
458 // hammering the server when we aren't successful in getting them. | 459 // hammering the server when we aren't successful in getting them. |
459 // crbug.com/373397 | 460 // crbug.com/373397 |
460 | 461 |
461 DCHECK(extension->version()); | 462 DCHECK(extension->version()); |
462 GURL url = | 463 GURL url = |
463 delegate_->GetSignatureFetchUrl(extension->id(), *extension->version()); | 464 delegate_->GetSignatureFetchUrl(extension->id(), *extension->version()); |
464 ContentHashFetcherJob* job = new ContentHashFetcherJob( | 465 ContentHashFetcherJob* job = new ContentHashFetcherJob( |
465 context_->GetRequestContext(), delegate_->GetPublicKey(), extension->id(), | 466 content::BrowserContext::GetDefaultStoragePartition(context_)-> |
| 467 GetURLRequestContext(), |
| 468 delegate_->GetPublicKey(), extension->id(), |
466 extension->path(), url, force, | 469 extension->path(), url, force, |
467 base::Bind(&ContentHashFetcher::JobFinished, | 470 base::Bind(&ContentHashFetcher::JobFinished, |
468 weak_ptr_factory_.GetWeakPtr())); | 471 weak_ptr_factory_.GetWeakPtr())); |
469 jobs_.insert(std::make_pair(key, job)); | 472 jobs_.insert(std::make_pair(key, job)); |
470 job->Start(); | 473 job->Start(); |
471 } | 474 } |
472 | 475 |
473 void ContentHashFetcher::ExtensionLoaded(const Extension* extension) { | 476 void ContentHashFetcher::ExtensionLoaded(const Extension* extension) { |
474 CHECK(extension); | 477 CHECK(extension); |
475 DoFetch(extension, false); | 478 DoFetch(extension, false); |
(...skipping 19 matching lines...) Expand all Loading... |
495 | 498 |
496 for (JobMap::iterator i = jobs_.begin(); i != jobs_.end(); ++i) { | 499 for (JobMap::iterator i = jobs_.begin(); i != jobs_.end(); ++i) { |
497 if (i->second.get() == job) { | 500 if (i->second.get() == job) { |
498 jobs_.erase(i); | 501 jobs_.erase(i); |
499 break; | 502 break; |
500 } | 503 } |
501 } | 504 } |
502 } | 505 } |
503 | 506 |
504 } // namespace extensions | 507 } // namespace extensions |
OLD | NEW |