17d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
27d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
37d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// found in the LICENSE file.
47d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
51320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#ifndef STORAGE_COMMON_DATABASE_DATABASE_IDENTIFIER_H_
61320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#define STORAGE_COMMON_DATABASE_DATABASE_IDENTIFIER_H_
7eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
87d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include <string>
97d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/basictypes.h"
117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/string_piece.h"
121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "storage/common/storage_common_export.h"
13eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "url/gurl.h"
147d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
1503b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)namespace storage {
167d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciSTORAGE_COMMON_EXPORT std::string GetIdentifierFromOrigin(
187d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    const GURL& origin);
191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano TucciSTORAGE_COMMON_EXPORT GURL GetOriginFromIdentifier(
207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)    const std::string& identifier);
217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass STORAGE_COMMON_EXPORT DatabaseIdentifier {
237d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) public:
247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  static const DatabaseIdentifier UniqueFileIdentifier();
257d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  static DatabaseIdentifier CreateFromOrigin(const GURL& origin);
267d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  static DatabaseIdentifier Parse(const std::string& identifier);
277d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  ~DatabaseIdentifier();
287d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
297d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  std::string ToString() const;
307d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  GURL ToOrigin() const;
317d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
327d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  std::string scheme() const { return scheme_; }
337d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  std::string hostname() const { return hostname_; }
347d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  int port() const { return port_; }
357d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  bool is_unique() const { return is_unique_; }
367d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
377d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) private:
387d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  DatabaseIdentifier();
397d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  DatabaseIdentifier(const std::string& scheme,
407d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)                     const std::string& hostname,
417d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)                     int port,
427d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)                     bool is_unique,
437d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)                     bool is_file);
447d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
457d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  std::string scheme_;
467d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  std::string hostname_;
477d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  int port_;
487d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  bool is_unique_;
497d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  bool is_file_;
507d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)};
517d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
5203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)}  // namespace storage
53eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#endif  // STORAGE_COMMON_DATABASE_DATABASE_IDENTIFIER_H_
55