[ledger] inline constants defined in headers
Hooray for C++17.
Test: Commit queue all the way.
Change-Id: Id335310cfbdf929f533b75bbfc44f9ee11b30d46
diff --git a/bin/ledger/app/constants.h b/bin/ledger/app/constants.h
index d1693ac..7b3da32 100644
--- a/bin/ledger/app/constants.h
+++ b/bin/ledger/app/constants.h
@@ -12,17 +12,17 @@
namespace ledger {
// The maximum key size.
-constexpr size_t kMaxKeySize = 256;
+inline constexpr size_t kMaxKeySize = 256;
// The root Page ID.
extern const fxl::StringView kRootPageId;
// Filename under which the server id used to sync a given user is stored within
// the repository dir of that user.
-constexpr fxl::StringView kServerIdFilename = "server_id";
+inline constexpr fxl::StringView kServerIdFilename = "server_id";
// The serialization version of PageUsage DB.
-constexpr fxl::StringView kPageUsageDbSerializationVersion = "1";
+inline constexpr fxl::StringView kPageUsageDbSerializationVersion = "1";
} // namespace ledger
diff --git a/bin/ledger/app/fidl/serialization_size.h b/bin/ledger/app/fidl/serialization_size.h
index 9713d43..165a205 100644
--- a/bin/ledger/app/fidl/serialization_size.h
+++ b/bin/ledger/app/fidl/serialization_size.h
@@ -16,23 +16,23 @@
namespace fidl_serialization {
// Maximal size of data that will be returned inline.
-constexpr size_t kMaxInlineDataSize = ZX_CHANNEL_MAX_MSG_BYTES * 9 / 10;
-constexpr size_t kMaxMessageHandles = ZX_CHANNEL_MAX_MSG_HANDLES;
+inline constexpr size_t kMaxInlineDataSize = ZX_CHANNEL_MAX_MSG_BYTES * 9 / 10;
+inline constexpr size_t kMaxMessageHandles = ZX_CHANNEL_MAX_MSG_HANDLES;
// TODO(mariagl): Remove dependency on FIDL internal structure layout, see
// LE-449.
-const size_t kPointerSize = sizeof(uintptr_t);
-const size_t kStatusEnumSize = sizeof(int32_t);
-const size_t kHandleSize = sizeof(zx_handle_t);
-const size_t kVectorHeaderSize = sizeof(fidl_vector_t);
-const size_t kPriorityEnumSize = sizeof(int32_t);
-const size_t kMessageHeaderSize = sizeof(fidl_message_header_t);
+inline constexpr size_t kPointerSize = sizeof(uintptr_t);
+inline constexpr size_t kStatusEnumSize = sizeof(int32_t);
+inline constexpr size_t kHandleSize = sizeof(zx_handle_t);
+inline constexpr size_t kVectorHeaderSize = sizeof(fidl_vector_t);
+inline constexpr size_t kPriorityEnumSize = sizeof(int32_t);
+inline constexpr size_t kMessageHeaderSize = sizeof(fidl_message_header_t);
inline size_t Align(size_t n) { return FIDL_ALIGN(n); }
// The overhead for storing the pointer, the timestamp (int64) and the two
// arrays.
-constexpr size_t kPageChangeHeaderSize =
+inline constexpr size_t kPageChangeHeaderSize =
kPointerSize + sizeof(int64_t) + 2 * kVectorHeaderSize;
// Returns the fidl size of a byte vector with the given length.
@@ -45,7 +45,7 @@
size_t GetInlinedEntrySize(const InlinedEntry& entry);
// Size of an object stored in memory (and accessed by a handle).
-constexpr size_t kMemoryObjectSize = 2 * kPointerSize + kHandleSize;
+inline constexpr size_t kMemoryObjectSize = 2 * kPointerSize + kHandleSize;
// Returns the size of a DiffEntry object
size_t GetDiffEntrySize(size_t key_length, int number_of_values);
diff --git a/bin/ledger/app/serialization_version.h b/bin/ledger/app/serialization_version.h
index a0c619c..0612b3b 100644
--- a/bin/ledger/app/serialization_version.h
+++ b/bin/ledger/app/serialization_version.h
@@ -5,11 +5,13 @@
#ifndef PERIDOT_BIN_LEDGER_APP_SERIALIZATION_VERSION_H_
#define PERIDOT_BIN_LEDGER_APP_SERIALIZATION_VERSION_H_
+#include <lib/fxl/strings/string_view.h>
+
namespace ledger {
// The serialization version of anything Ledger stores on local storage
// (directory structure, object/LevelDb serialization).
-constexpr fxl::StringView kSerializationVersion = "29";
+inline constexpr fxl::StringView kSerializationVersion = "29";
} // namespace ledger
diff --git a/bin/ledger/cloud_sync/impl/constants.h b/bin/ledger/cloud_sync/impl/constants.h
index 22d2409..0ac138b 100644
--- a/bin/ledger/cloud_sync/impl/constants.h
+++ b/bin/ledger/cloud_sync/impl/constants.h
@@ -10,7 +10,7 @@
namespace cloud_sync {
// Key for the timestamp metadata in the SyncMetadata KV store.
-constexpr fxl::StringView kTimestampKey = "timestamp";
+inline constexpr fxl::StringView kTimestampKey = "timestamp";
} // namespace cloud_sync
diff --git a/bin/ledger/coroutine/context/arm64/context.h b/bin/ledger/coroutine/context/arm64/context.h
index d9565f8..62118d8 100644
--- a/bin/ledger/coroutine/context/arm64/context.h
+++ b/bin/ledger/coroutine/context/arm64/context.h
@@ -73,7 +73,7 @@
REG_LR = REG_X30,
};
-constexpr size_t kAdditionalStackAlignment = 0;
+inline constexpr size_t kAdditionalStackAlignment = 0;
struct InternalContext {
uint64_t registers[NUM_REGISTERS];
diff --git a/bin/ledger/coroutine/context/x64/context.h b/bin/ledger/coroutine/context/x64/context.h
index 8fe449e..fbc68fc 100644
--- a/bin/ledger/coroutine/context/x64/context.h
+++ b/bin/ledger/coroutine/context/x64/context.h
@@ -48,7 +48,7 @@
REG_SP = REG_RSP,
};
-constexpr size_t kAdditionalStackAlignment = 8;
+inline constexpr size_t kAdditionalStackAlignment = 8;
struct InternalContext {
uint64_t registers[NUM_REGISTERS];
diff --git a/bin/ledger/encryption/primitives/hash.h b/bin/ledger/encryption/primitives/hash.h
index d48b3eb..0c79d5d 100644
--- a/bin/ledger/encryption/primitives/hash.h
+++ b/bin/ledger/encryption/primitives/hash.h
@@ -13,7 +13,7 @@
namespace encryption {
-constexpr static size_t kHashSize = 32;
+inline constexpr size_t kHashSize = 32;
std::string SHA256WithLengthHash(fxl::StringView data);
diff --git a/bin/ledger/storage/impl/constants.h b/bin/ledger/storage/impl/constants.h
index 87a0c61..cad4fa7 100644
--- a/bin/ledger/storage/impl/constants.h
+++ b/bin/ledger/storage/impl/constants.h
@@ -7,7 +7,7 @@
namespace storage {
-constexpr size_t kStorageHashSize = 32;
+inline constexpr size_t kStorageHashSize = 32;
} // namespace storage
diff --git a/bin/ledger/storage/impl/storage_test_utils.h b/bin/ledger/storage/impl/storage_test_utils.h
index bb3122a..51c23e9 100644
--- a/bin/ledger/storage/impl/storage_test_utils.h
+++ b/bin/ledger/storage/impl/storage_test_utils.h
@@ -20,7 +20,7 @@
// A sufficiently large delay, such that if a storagemethod posts a delayed
// task, the task will be due after associated amount of time.
-constexpr zx::duration kSufficientDelay = zx::hour(1);
+inline constexpr zx::duration kSufficientDelay = zx::hour(1);
// Enum describing the expected behavior for identifier, allowing or preventing
// to be inlined values.
diff --git a/bin/ledger/storage/public/BUILD.gn b/bin/ledger/storage/public/BUILD.gn
index 76a34a2..cd5d3c0 100644
--- a/bin/ledger/storage/public/BUILD.gn
+++ b/bin/ledger/storage/public/BUILD.gn
@@ -10,6 +10,7 @@
sources = [
"commit.h",
"commit_watcher.h",
+ "constants.cc",
"constants.h",
"data_source.cc",
"data_source.h",
diff --git a/bin/ledger/storage/public/constants.cc b/bin/ledger/storage/public/constants.cc
new file mode 100644
index 0000000..81e4ec9
--- /dev/null
+++ b/bin/ledger/storage/public/constants.cc
@@ -0,0 +1,17 @@
+// Copyright 2016 The Fuchsia 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 "peridot/bin/ledger/storage/public/constants.h"
+
+#include <lib/fxl/strings/string_view.h>
+
+namespace storage {
+
+namespace {
+constexpr char kFirstPageCommitIdArray[kCommitIdSize] = {};
+} // namespace
+
+constexpr fxl::StringView kFirstPageCommitId(kFirstPageCommitIdArray,
+ kCommitIdSize);
+} // namespace storage
diff --git a/bin/ledger/storage/public/constants.h b/bin/ledger/storage/public/constants.h
index c135574..925823b 100644
--- a/bin/ledger/storage/public/constants.h
+++ b/bin/ledger/storage/public/constants.h
@@ -12,13 +12,10 @@
namespace storage {
// The size of a commit id in number of bytes.
-constexpr uint64_t kCommitIdSize = 32;
+inline constexpr uint64_t kCommitIdSize = 32;
-// The id of the first commit of a page.
-constexpr char kFirstPageCommitIdArray[kCommitIdSize] = {0};
-constexpr fxl::StringView kFirstPageCommitId(kFirstPageCommitIdArray,
- kCommitIdSize);
-
+// The ID of the first commit of a page.
+extern const fxl::StringView kFirstPageCommitId;
} // namespace storage
#endif // PERIDOT_BIN_LEDGER_STORAGE_PUBLIC_CONSTANTS_H_
diff --git a/lib/ledger_client/constants.h b/lib/ledger_client/constants.h
index 32656f1..00c7b7a 100644
--- a/lib/ledger_client/constants.h
+++ b/lib/ledger_client/constants.h
@@ -7,12 +7,14 @@
namespace modular {
-constexpr char kCloudProviderFirestoreAppUrl[] = "cloud_provider_firestore";
-constexpr char kLedgerAppUrl[] = "ledger";
+inline constexpr char kCloudProviderFirestoreAppUrl[] =
+ "cloud_provider_firestore";
+inline constexpr char kLedgerAppUrl[] = "ledger";
// Hard-coded communal Ledger instance.
-const char kFirebaseProjectId[] = "fuchsia-ledger";
-const char kFirebaseApiKey[] = "AIzaSyDzzuJILOn6riFPTXC36HlH6CEdliLapDA";
+inline constexpr char kFirebaseProjectId[] = "fuchsia-ledger";
+inline constexpr char kFirebaseApiKey[] =
+ "AIzaSyDzzuJILOn6riFPTXC36HlH6CEdliLapDA";
} // namespace modular