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

Unified Diff: net/cert_net/cert_net_fetcher_impl.h

Issue 908863004: Initial implementation for CertNetFetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address more feedback Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: net/cert_net/cert_net_fetcher_impl.h
diff --git a/net/cert_net/cert_net_fetcher_impl.h b/net/cert_net/cert_net_fetcher_impl.h
new file mode 100644
index 0000000000000000000000000000000000000000..4fac570cf09614c781ae5a84ffab7c2f9fd10419
--- /dev/null
+++ b/net/cert_net/cert_net_fetcher_impl.h
@@ -0,0 +1,107 @@
+// 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 NET_CERT_NET_CERT_NET_FETCHER_H_
+#define NET_CERT_NET_CERT_NET_FETCHER_H_
+
+#include <set>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "net/base/net_errors.h"
+#include "net/base/net_export.h"
+#include "net/cert/cert_net_fetcher.h"
+
+namespace net {
+
+class URLRequestContext;
+
+// CertNetFetcherImpl is an implementation of CertNetFetcher that uses the
+// network stack.
+//
+// For more details refer to the documentation for the interface.
+class NET_EXPORT CertNetFetcherImpl : public CertNetFetcher {
+ public:
+ using FetchCallback =
+ base::Callback<void(Error, const std::vector<uint8_t>&)>;
+
+ // Initializes CertNetFetcherImpl using the specified URLRequestContext for
+ // issuing requests. |context| must remain valid for the entire lifetime of
+ // the CertNetFetcherImpl.
+ explicit CertNetFetcherImpl(URLRequestContext* context);
+
+ // Deletion implicitly cancels any outstanding requests.
+ ~CertNetFetcherImpl() override;
+
+ void CancelRequest(RequestId request_id) override;
+
+ RequestId FetchCaIssuers(const GURL& url,
+ int timeout_milliseconds,
+ int max_response_bytes,
+ const FetchCallback& callback) override;
+
+ RequestId FetchCrl(const GURL& url,
+ int timeout_milliseconds,
+ int max_response_bytes,
+ const FetchCallback& callback) override;
+
+ RequestId FetchOcsp(const GURL& url,
+ int timeout_milliseconds,
+ int max_response_bytes,
+ const FetchCallback& callback) override;
+
+ private:
+ struct Request;
+ class Job;
+ struct JobToRequestParamsComparator;
+ struct RequestParams;
davidben 2015/03/27 23:34:32 Nit: ordering. I think it's classes before structs
+
+ struct JobComparator {
+ bool operator()(const Job* job1, const Job* job2) const;
+ };
+
+ using JobSet = std::set<Job*, JobComparator>;
+
+ // Starts an asynchronous request to fetch the given URL. On completion
+ // |callback| will be invoked.
+ //
+ // Completion of the request will never occur synchronously. In other words it
+ // is guaranteed that |callback| will only be invoked once the Fetch*() method
+ // has returned.
+ RequestId Fetch(scoped_ptr<RequestParams> request_params,
+ const FetchCallback& callback);
+
+ // Finds a job with a matching RequestPararms or returns NULL if there was no
+ // match.
+ Job* FindJob(const RequestParams& params);
+
+ // Removes |job| from the in progress jobs and transfers ownership to the
+ // caller.
+ scoped_ptr<Job> RemoveJob(Job* job);
+
+ // Indicates which Job is currently executing inside of OnJobCompleted().
+ void SetCurrentlyCompletingJob(Job* job);
+
+ // The in-progress jobs. This set does not contain the job which is actively
+ // invoking callbacks (OnJobCompleted). Instead that is tracked by
+ // |currently_completing_job_|.
+ JobSet jobs_;
+
+ // The Job that is currently executing OnJobCompleted(). There can be at most
+ // one such job. This pointer is not owned.
+ Job* currently_completing_job_;
+
+ // Not owned. CertNetFetcherImpl must outlive the URLRequestContext.
+ URLRequestContext* context_;
+
+ base::ThreadChecker thread_checker_;
+
+ DISALLOW_COPY_AND_ASSIGN(CertNetFetcherImpl);
+};
+
+} // namespace net
+
+#endif // NET_CERT_NET_CERT_NET_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698