Index: components/certificate_transparency/log_proof_fetcher.h |
diff --git a/components/certificate_transparency/log_proof_fetcher.h b/components/certificate_transparency/log_proof_fetcher.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..03acaac21fb59af98bc937b209daf110688b7e14 |
--- /dev/null |
+++ b/components/certificate_transparency/log_proof_fetcher.h |
@@ -0,0 +1,75 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_PROOF_FETCHER_H_ |
+#define COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_PROOF_FETCHER_H_ |
+ |
+#include <map> |
+#include <string> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "net/url_request/url_request.h" |
+#include "url/gurl.h" |
+ |
+namespace base { |
+class Value; |
+} // namespace base |
+ |
+namespace net { |
+class URLRequestContext; |
+ |
+namespace ct { |
+struct SignedTreeHead; |
+} // namespace ct |
+ |
+} // namespace net |
+ |
+namespace certificate_transparency { |
+ |
+// Fetches STHs and consistency proofs from Certificate Transparency logs |
+// using the URLRequestContext provided during the instance construction. |
+class LogProofFetcher : public net::URLRequest::Delegate { |
+ public: |
+ typedef base::Callback<void(const std::string&, |
+ const net::ct::SignedTreeHead&)> FetchSTHCallback; |
+ explicit LogProofFetcher(net::URLRequestContext* request_context); |
Ryan Sleevi
2015/06/29 11:58:13
Document the lifetime requirements re: |request_co
|
+ ~LogProofFetcher() override; |
+ |
+ // Fetch the latest Signed Tree Head from the log identified by |verifier| |
+ void FetchSTH(const GURL& log_url, |
+ const std::string& log_id, |
+ FetchSTHCallback fetched_cb); |
+ |
+ // net::URLRequest::Delegate |
+ void OnResponseStarted(net::URLRequest* request) override; |
+ void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
+ |
+ private: |
+ struct FetchParams; |
+ |
+ scoped_ptr<net::URLRequest> CreateURLRequest(const GURL& fetch_sth_url); |
+ |
+ // Performs post-report cleanup. |
+ void RequestComplete(net::URLRequest* request, int bytes_read); |
+ void CleanupRequest(net::URLRequest* request); |
+ |
+ // Callbacks for parsing the STH's JSON by the SafeJsonParser |
+ void OnSTHJsonParseSuccess(FetchParams params, |
+ scoped_ptr<base::Value> parsed_json); |
+ void OnSTHJsonParseError(FetchParams params, const std::string& error); |
+ |
+ net::URLRequestContext* const request_context_; |
+ |
+ // Owns the contained requests. |
+ std::map<net::URLRequest*, FetchParams*> inflight_requests_; |
+ |
+ base::WeakPtrFactory<LogProofFetcher> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(LogProofFetcher); |
+}; |
+ |
+} // namespace certificate_transparency |
+ |
+#endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_PROOF_FETCHER_H_ |