• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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 #ifndef WEBKIT_COMMON_DATABASE_DATABASE_IDENTIFIER_H_
6 #define WEBKIT_COMMON_DATABASE_DATABASE_IDENTIFIER_H_
7 
8 #include <string>
9 
10 #include "base/basictypes.h"
11 #include "base/strings/string_piece.h"
12 #include "url/gurl.h"
13 #include "webkit/common/webkit_storage_common_export.h"
14 
15 namespace webkit_database {
16 
17 WEBKIT_STORAGE_COMMON_EXPORT std::string GetIdentifierFromOrigin(
18     const GURL& origin);
19 WEBKIT_STORAGE_COMMON_EXPORT GURL GetOriginFromIdentifier(
20     const std::string& identifier);
21 
22 class WEBKIT_STORAGE_COMMON_EXPORT DatabaseIdentifier {
23  public:
24   static const DatabaseIdentifier UniqueFileIdentifier();
25   static DatabaseIdentifier CreateFromOrigin(const GURL& origin);
26   static DatabaseIdentifier Parse(const std::string& identifier);
27   ~DatabaseIdentifier();
28 
29   std::string ToString() const;
30   GURL ToOrigin() const;
31 
scheme()32   std::string scheme() const { return scheme_; }
hostname()33   std::string hostname() const { return hostname_; }
port()34   int port() const { return port_; }
is_unique()35   bool is_unique() const { return is_unique_; }
36 
37  private:
38   DatabaseIdentifier();
39   DatabaseIdentifier(const std::string& scheme,
40                      const std::string& hostname,
41                      int port,
42                      bool is_unique,
43                      bool is_file);
44 
45   std::string scheme_;
46   std::string hostname_;
47   int port_;
48   bool is_unique_;
49   bool is_file_;
50 };
51 
52 }  // namespace webkit_database
53 
54 #endif  // WEBKIT_COMMON_DATABASE_DATABASE_IDENTIFIER_H_
55