Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(570)

Side by Side Diff: components/certificate_transparency/log_proof_fetcher.h

Issue 1222953002: Certificate Transparency: Add STH Fetching capability. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing review comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_PROOF_FETCHER_H_
6 #define COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_PROOF_FETCHER_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/url_request/url_request.h"
14 #include "url/gurl.h"
15
16 namespace base {
17 class Value;
18 } // namespace base
19
20 namespace net {
21
22 class URLRequestContext;
23
24 namespace ct {
25 struct SignedTreeHead;
26 } // namespace ct
27
28 } // namespace net
29
30 namespace certificate_transparency {
31
32 // Fetches STHs and consistency proofs from Certificate Transparency logs
33 // using the URLRequestContext provided during the instance construction.
34 class LogProofFetcher : public net::URLRequest::Delegate {
35 public:
36 using FetchSTHCallback =
mmenke 2015/07/17 17:57:47 Google style discourages use of uncommon abbreviat
Eran Messeri 2015/07/29 15:16:59 Done, renamed to SignedTreeHeadFetchedCallback. Al
37 base::Callback<void(const std::string&, const net::ct::SignedTreeHead&)>;
38 using FetchFailedCallback = base::Callback<void(const std::string&, int)>;
mmenke 2015/07/17 17:57:47 I believe the callback arguments should be named
mmenke 2015/07/17 17:57:48 Callbacks should be documented.
mmenke 2015/07/17 17:57:48 Need to include callback header.
Eran Messeri 2015/07/29 15:16:59 Done.
Eran Messeri 2015/07/29 15:16:59 Done.
Eran Messeri 2015/07/29 15:16:59 Done.
39 explicit LogProofFetcher(net::URLRequestContext* request_context);
mmenke 2015/07/17 17:57:48 nit: Add blank line above constructor.
Eran Messeri 2015/07/29 15:16:59 Done.
40 ~LogProofFetcher() override;
41
42 // Fetch the latest Signed Tree Head from the log identified by |log_id|
43 // from |log_url|.
44 void FetchSTH(const GURL& log_url,
45 const std::string& log_id,
46 FetchSTHCallback fetched_cb,
47 FetchFailedCallback failed_cb);
mmenke 2015/07/17 17:57:47 Write out callback.
mmenke 2015/07/17 17:57:47 Callbacks are generally passed via const ref (Even
Eran Messeri 2015/07/29 15:16:59 Done.
Eran Messeri 2015/07/29 15:16:59 Done.
48
49 // net::URLRequest::Delegate
50 void OnResponseStarted(net::URLRequest* request) override;
51 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
52
53 private:
54 struct FetchState;
55
56 bool CheckReadStatus(net::URLRequest* request, FetchState* params);
57 void KickOffARead(net::URLRequest* request, FetchState* params);
58
59 // Performs post-report cleanup.
60 void RequestComplete(net::URLRequest* request);
61 // Returns the FetchState associated with the request. The caller takes
62 // ownership of the returned value in case the params should be used before
63 // being deleted.
64 scoped_ptr<FetchState> CleanupRequest(net::URLRequest* request);
65
66 // Actually create the request
67 scoped_ptr<net::URLRequest> CreateURLRequest(const GURL& fetch_sth_url);
68
69 // Callbacks for parsing the STH's JSON by the SafeJsonParser
70 void OnSTHJsonParseSuccess(FetchState params,
71 scoped_ptr<base::Value> parsed_json);
72 void OnSTHJsonParseError(FetchState params, const std::string& error);
73
74 net::URLRequestContext* const request_context_;
75
76 // Owns the contained requests, as well as FetchState.
77 std::map<net::URLRequest*, FetchState*> inflight_requests_;
78
79 base::WeakPtrFactory<LogProofFetcher> weak_factory_;
mmenke 2015/07/17 17:57:47 Include weak_ptr.h
Eran Messeri 2015/07/29 15:16:59 Done.
80
81 DISALLOW_COPY_AND_ASSIGN(LogProofFetcher);
mmenke 2015/07/17 17:57:47 Include base/macros.h for DISALLOW_COPY_AND_ASSIGN
Eran Messeri 2015/07/29 15:16:59 Done.
82 };
83
84 } // namespace certificate_transparency
85
86 #endif // COMPONENTS_CERTIFICATE_TRANSPARENCY_LOG_PROOF_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698