1 // Copyright (c) 2012 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.
5 #ifndef NET_SPDY_SPDY_CREDENTIAL_STATE_H_
6 #define NET_SPDY_SPDY_CREDENTIAL_STATE_H_
10 #include "googleurl/src/gurl.h"
11 #include "net/base/net_export.h"
15 // A class for tracking the credentials associated with a SPDY session.
16 class NET_EXPORT_PRIVATE SpdyCredentialState
{
18 explicit SpdyCredentialState(size_t num_slots
);
19 ~SpdyCredentialState();
21 // Changes the number of credentials being tracked. If the new size is
22 // larger, then empty slots will be added to the end. If the new size is
23 // smaller than the current size, then the extra slots will be truncated
25 void Resize(size_t size
);
27 // Returns the one-based index in |slots_| for |url| or kNoEntry, if no entry
29 size_t FindCredentialSlot(const GURL
& url
) const;
31 // Returns true if there is a credential associated with |url|.
32 bool HasCredential(const GURL
& url
) const;
34 // Adds the new credentials to be associated with all origins matching
35 // |url|. If there is space, then it will add in the first available
36 // position. Otherwise, an existing credential will be evicted. Returns
37 // the slot in which this domain was added.
38 size_t SetHasCredential(const GURL
& url
);
40 // This value is defined as the default initial value in the SPDY spec unless
41 // otherwise negotiated via SETTINGS.
42 static const size_t kDefaultNumSlots
;
44 // Sentinel value to be returned by FindCredentialSlot when no entry exists.
45 static const size_t kNoEntry
;
48 // Vector of origins that have credentials.
49 std::vector
<GURL
> slots_
;
50 // Index of the last origin added to |slots_|.
56 #endif // NET_SPDY_SPDY_CREDENTIAL_STATE_H_