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