summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync_file_system/remote_metadata_store.h
blob: 440eda8f8bfc90ed1bf1e1ba46471aeab14c8be1 (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
64
65
66
67
68
69
70
// Copyright (c) 2012 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 CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_METADATA_STORE_H_
#define CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_METADATA_STORE_H_

#include "base/callback_forward.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/non_thread_safe.h"

namespace base {
class SequencedTaskRunner;
}

namespace fileapi {
class FileSystemURL;
}

namespace gdata {
class DocumentFeed;
}

class FilePath;
class GURL;

namespace sync_file_system {

class RemoteMetadataDatabase;

// This class holds snapshot of server side metadata..
class RemoteMetadataStore
    : public base::NonThreadSafe,
      public base::SupportsWeakPtr<RemoteMetadataStore> {
 public:
  typedef base::Callback<void(bool success, bool has_cache)>
      InitializationCallback;

  RemoteMetadataStore(const FilePath& base_dir,
                      base::SequencedTaskRunner* file_task_runner);
  ~RemoteMetadataStore();

  void InitializeFromDiskCache(const InitializationCallback& callback);
  void InitializeWithDocumentFeed(scoped_ptr<gdata::DocumentFeed> feed,
                                  const InitializationCallback& callback);

  void SetLargestChangeStamp(int64 largest_changestamp);
  int64 GetLargestChangeStamp() const;

  void ApplyChangeFeed(scoped_ptr<gdata::DocumentFeed> feed);

  std::string GetResourceId(const fileapi::FileSystemURL& url) const;
  std::string GetETag(const fileapi::FileSystemURL& url) const;
  GURL GetDownloadURL(const fileapi::FileSystemURL& url) const;
  GURL GetUploadURL(const fileapi::FileSystemURL& url) const;

 private:
  scoped_ptr<RemoteMetadataDatabase> db_;
  scoped_refptr<base::SequencedTaskRunner> file_task_runner_;

  bool db_disabled_;
  int64 largest_changestamp_;

  DISALLOW_COPY_AND_ASSIGN(RemoteMetadataStore);
};

}  // namespace sync_file_system

#endif  // CHROME_BROWSER_SYNC_FILE_SYSTEM_REMOTE_METADATA_STORE_H_