• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 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.
4 
5 #ifndef SYNC_SYNCABLE_NIGORI_HANDLER_H_
6 #define SYNC_SYNCABLE_NIGORI_HANDLER_H_
7 
8 #include "sync/base/sync_export.h"
9 #include "sync/internal_api/public/base/model_type.h"
10 
11 namespace google{
12 namespace protobuf{
13 template <typename T>
14 class RepeatedPtrField;
15 }
16 }
17 
18 namespace sync_pb {
19 class NigoriSpecifics;
20 }
21 
22 namespace syncer {
23 namespace syncable {
24 
25 class BaseTransaction;
26 
27 // Sync internal interface for dealing with nigori node and querying
28 // the current set of encrypted types. Not thread safe, so a sync transaction
29 // must be held by a caller whenever invoking methods.
30 class SYNC_EXPORT_PRIVATE NigoriHandler {
31  public:
32   NigoriHandler();
33   virtual ~NigoriHandler();
34 
35   // Apply a nigori node update, updating the internal encryption state
36   // accordingly.
37   virtual void ApplyNigoriUpdate(
38       const sync_pb::NigoriSpecifics& nigori,
39       syncable::BaseTransaction* const trans) = 0;
40 
41   // Store the current encrypt everything/encrypted types state into |nigori|.
42   virtual void UpdateNigoriFromEncryptedTypes(
43       sync_pb::NigoriSpecifics* nigori,
44       syncable::BaseTransaction* const trans) const = 0;
45 
46   // Whether a keystore key needs to be requested from the sync server.
47   virtual bool NeedKeystoreKey(
48       syncable::BaseTransaction* const trans) const = 0;
49 
50   // Set the keystore keys the server returned for this account.
51   // Returns true on success, false otherwise.
52   virtual bool SetKeystoreKeys(
53       const google::protobuf::RepeatedPtrField<std::string>& keys,
54       syncable::BaseTransaction* const trans) = 0;
55 
56   // Returns the set of currently encrypted types.
57   virtual ModelTypeSet GetEncryptedTypes(
58       syncable::BaseTransaction* const trans) const = 0;
59 };
60 
61 }  // namespace syncable
62 }  // namespace syncer
63 
64 #endif  // SYNC_SYNCABLE_NIGORI_HANDLER_H_
65