1 // Copyright (c) 2012 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 THIRD_PARTY_BLINK_PUBLIC_COMMON_INDEXEDDB_INDEXEDDB_KEY_PATH_H_
6 #define THIRD_PARTY_BLINK_PUBLIC_COMMON_INDEXEDDB_INDEXEDDB_KEY_PATH_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "base/logging.h"
12 #include "base/strings/string16.h"
13 #include "third_party/blink/public/common/common_export.h"
14 #include "third_party/blink/public/common/indexeddb/web_idb_types.h"
15 #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-shared.h"
16 
17 namespace blink {
18 
19 class BLINK_COMMON_EXPORT IndexedDBKeyPath {
20  public:
21   IndexedDBKeyPath();  // Defaults to blink::WebIDBKeyPathTypeNull.
22   explicit IndexedDBKeyPath(const base::string16&);
23   explicit IndexedDBKeyPath(const std::vector<base::string16>&);
24   IndexedDBKeyPath(const IndexedDBKeyPath& other);
25   IndexedDBKeyPath(IndexedDBKeyPath&& other);
26   ~IndexedDBKeyPath();
27   IndexedDBKeyPath& operator=(const IndexedDBKeyPath& other);
28   IndexedDBKeyPath& operator=(IndexedDBKeyPath&& other);
29 
IsNull()30   bool IsNull() const { return type_ == blink::mojom::IDBKeyPathType::Null; }
31   bool operator==(const IndexedDBKeyPath& other) const;
32 
type()33   mojom::IDBKeyPathType type() const { return type_; }
34   const std::vector<base::string16>& array() const;
35   const base::string16& string() const;
36 
37  private:
38   mojom::IDBKeyPathType type_;
39   base::string16 string_;
40   std::vector<base::string16> array_;
41 };
42 
43 }  // namespace blink
44 
45 #endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_INDEXEDDB_INDEXEDDB_KEY_PATH_H_
46