attachment_id.cc revision 23730a6e56a168d1879203e4b3819bb36e3d8f1f
1// Copyright 2014 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#include "sync/api/attachments/attachment_id.h" 6 7#include "base/logging.h" 8#include "base/rand_util.h" 9 10namespace syncer { 11 12AttachmentId::~AttachmentId() {} 13 14bool AttachmentId::operator==(const AttachmentId& other) const { 15 return unique_id_ == other.unique_id_; 16} 17 18bool AttachmentId::operator!=(const AttachmentId& other) const { 19 return !operator==(other); 20} 21 22bool AttachmentId::operator<(const AttachmentId& other) const { 23 return unique_id_ < other.unique_id_; 24} 25 26// Static. 27AttachmentId AttachmentId::Create() { 28 // Only requirement here is that this id must be globally unique. 29 // TODO(maniscalco): Consider making this base64 encoded. 30 return AttachmentId(base::RandBytesAsString(16)); 31} 32 33AttachmentId::AttachmentId(const std::string& unique_id) 34 : unique_id_(unique_id) { 35 DCHECK(!unique_id_.empty()); 36} 37 38} // namespace syncer 39