1f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 2f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// found in the LICENSE file. 4f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 5f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_SIGNED_CERTIFICATE_TIMESTAMP_STORE_H_ 6f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_SIGNED_CERTIFICATE_TIMESTAMP_STORE_H_ 7f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 8f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "base/memory/ref_counted.h" 9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "content/common/content_export.h" 10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 11f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace net { 12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace ct { 13f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)struct SignedCertificateTimestamp; 14f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)} // namespace ct 15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)} // namespace net 16f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 17f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)namespace content { 18f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 19f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// The purpose of the SignedCertificateTimestampStore is to provide an easy way 20f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// to store/retrieve SignedCertificateTimestamp objects. When stored, 21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// SignedCertificateTimestamp objects are associated with a RenderProcessHost. 22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// If all the RenderProcessHosts associated with the SCT have exited, the SCT 23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// is removed from the store. This class is used by the SSLManager to keep 24f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// track of the SCTs associated with loaded resources. It can be accessed from 25f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// the UI and IO threads (it is thread-safe). Note that the SCT ids will 26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// overflow if we register more than 2^32 - 1 SCTs in 1 browsing session (which 27f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// is highly unlikely to happen). 28f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class SignedCertificateTimestampStore { 29f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) public: 30f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Returns the singleton instance of the SignedCertificateTimestampStore. 31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) CONTENT_EXPORT static SignedCertificateTimestampStore* GetInstance(); 32f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 33f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Stores the specified SCT and returns the id associated with it. The SCT 34f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // is associated with the specified RenderProcessHost. 35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // When all the RenderProcessHosts associated with a SCT have exited, the 36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // SCT is removed from the store. 37f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Note: ids start at 1. 38f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual int Store(net::ct::SignedCertificateTimestamp* sct, 39f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) int render_process_host_id) = 0; 40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 41f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Tries to retrieve the previously stored SCT associated with the specified 42f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // |sct_id|. Returns whether the SCT could be found, and, if |sct| is 43f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // non-NULL, copies it in. 44f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual bool Retrieve( 45f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) int sct_id, scoped_refptr<net::ct::SignedCertificateTimestamp>* sct) = 0; 46f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 47f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) protected: 48f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual ~SignedCertificateTimestampStore() {} 49f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}; 50f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 51f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)} // namespace content 52f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 53f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#endif // CONTENT_PUBLIC_BROWSER_SIGNED_CERTIFICATE_TIMESTAMP_STORE_H_ 54