summaryrefslogtreecommitdiffstats
path: root/net/quic/crypto/channel_id_chromium.h
blob: 20a1d8d7aa84041d6bd7d85409ff250b260d0907 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2014 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_QUIC_CRYPTO_CHANNEL_ID_CHROMIUM_H_
#define NET_QUIC_CRYPTO_CHANNEL_ID_CHROMIUM_H_

#include <set>

#include "net/quic/crypto/channel_id.h"

namespace crypto {
class ECPrivateKey;
}  // namespace crypto

namespace net {

class ChannelIDService;

class NET_EXPORT_PRIVATE ChannelIDKeyChromium: public ChannelIDKey {
 public:
  explicit ChannelIDKeyChromium(crypto::ECPrivateKey* ec_private_key);
  ~ChannelIDKeyChromium() override;

  // ChannelIDKey interface
  bool Sign(base::StringPiece signed_data,
            std::string* out_signature) const override;
  std::string SerializeKey() const override;

 private:
  scoped_ptr<crypto::ECPrivateKey> ec_private_key_;
};

// ChannelIDSourceChromium implements the QUIC ChannelIDSource interface.
class ChannelIDSourceChromium : public ChannelIDSource {
 public:
  explicit ChannelIDSourceChromium(
      ChannelIDService* channel_id_service);
  ~ChannelIDSourceChromium() override;

  // ChannelIDSource interface
  QuicAsyncStatus GetChannelIDKey(const std::string& hostname,
                                  scoped_ptr<ChannelIDKey>* channel_id_key,
                                  ChannelIDSourceCallback* callback) override;

 private:
  class Job;
  typedef std::set<Job*> JobSet;

  void OnJobComplete(Job* job);

  // Set owning pointers to active jobs.
  JobSet active_jobs_;

  // The service for retrieving Channel ID keys.
  ChannelIDService* const channel_id_service_;

  DISALLOW_COPY_AND_ASSIGN(ChannelIDSourceChromium);
};

}  // namespace net

#endif  // NET_QUIC_CRYPTO_CHANNEL_ID_CHROMIUM_H_