Home | History | Annotate | Download | only in crypto
      1 // Copyright 2013 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 NET_QUIC_CRYPTO_STRIKE_REGISTER_CLIENT_H_
      6 #define NET_QUIC_CRYPTO_STRIKE_REGISTER_CLIENT_H_
      7 
      8 #include <string>
      9 
     10 #include "base/strings/string_piece.h"
     11 #include "net/base/net_export.h"
     12 #include "net/quic/quic_time.h"
     13 
     14 namespace net {
     15 
     16 // Interface implemented by clients that talk to strike registers
     17 // implemented as local or remote services.
     18 class NET_EXPORT_PRIVATE StrikeRegisterClient {
     19  public:
     20   // Single use callback that will be invoked once the validation
     21   // operation is complete.
     22   class NET_EXPORT_PRIVATE ResultCallback {
     23    public:
     24     ResultCallback() {}
     25     virtual ~ResultCallback() {}
     26     void Run(bool nonce_is_valid_and_unique) {
     27       RunImpl(nonce_is_valid_and_unique);
     28       delete this;
     29     }
     30 
     31    protected:
     32     virtual void RunImpl(bool nonce_is_valid_and_unique) = 0;
     33 
     34    private:
     35     DISALLOW_COPY_AND_ASSIGN(ResultCallback);
     36   };
     37 
     38   StrikeRegisterClient() {}
     39   virtual ~StrikeRegisterClient() {}
     40 
     41   // Returns the strike server orbit if known, else empty string.
     42   virtual std::string orbit() = 0;
     43   // Validate a nonce for freshness and uniqueness.
     44   // Will invoke cb->Run(ValidateResponse::nonce_is_valid_and_unique())
     45   // once the asynchronous operation is complete.
     46   virtual void VerifyNonceIsValidAndUnique(
     47       base::StringPiece nonce,
     48       QuicWallTime now,
     49       ResultCallback* cb) = 0;
     50 
     51  private:
     52   DISALLOW_COPY_AND_ASSIGN(StrikeRegisterClient);
     53 };
     54 
     55 }  // namespace net
     56 
     57 #endif  // NET_QUIC_CRYPTO_STRIKE_REGISTER_CLIENT_H_
     58