summaryrefslogtreecommitdiffstats
path: root/extensions/browser/value_store/value_store.cc
blob: c198f1055661cfe84d20a628dcf7c4c93e30dea1 (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
// 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.

#include "extensions/browser/value_store/value_store.h"

#include <utility>

#include "base/logging.h"

// Implementation of Status.

ValueStore::Status::Status() : code(OK), restore_status(RESTORE_NONE) {}

ValueStore::Status::Status(StatusCode code, const std::string& message)
    : Status(code, RESTORE_NONE, message) {}

ValueStore::Status::Status(StatusCode code,
                           BackingStoreRestoreStatus restore_status,
                           const std::string& message)
    : code(code), restore_status(restore_status), message(message) {}

ValueStore::Status::~Status() {}

void ValueStore::Status::Merge(const Status& status) {
  if (code == OK)
    code = status.code;
  if (message.empty() && !status.message.empty())
    message = status.message;
  if (restore_status == RESTORE_NONE)
    restore_status = status.restore_status;
}

// Implementation of ReadResultType.

ValueStore::ReadResultType::ReadResultType(
    scoped_ptr<base::DictionaryValue> settings,
    const Status& status)
    : settings_(std::move(settings)), status_(status) {
  CHECK(settings_);
}

ValueStore::ReadResultType::ReadResultType(const Status& status)
    : status_(status) {}

ValueStore::ReadResultType::~ReadResultType() {}

// Implementation of WriteResultType.

ValueStore::WriteResultType::WriteResultType(
    scoped_ptr<ValueStoreChangeList> changes,
    const Status& status)
    : changes_(std::move(changes)), status_(status) {
  CHECK(changes_);
}

ValueStore::WriteResultType::WriteResultType(const Status& status)
    : status_(status) {}

ValueStore::WriteResultType::~WriteResultType() {}