summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_url.h
blob: 1d1d57956b957e1f01e369be7f39f3cbb8049c04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_
#define WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_

#include <string>

#include "base/file_path.h"
#include "base/platform_file.h"
#include "googleurl/src/gurl.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/fileapi/fileapi_export.h"

namespace fileapi {

// A class representing a filesystem URL which consists of origin URL,
// type and an internal path used inside the filesystem.
class FILEAPI_EXPORT FileSystemURL {
 public:
  FileSystemURL();
  explicit FileSystemURL(const GURL& filesystem_url);
  FileSystemURL(const GURL& origin,
                FileSystemType type,
                const FilePath& internal_path);
  ~FileSystemURL();

  bool is_valid() const { return is_valid_; }
  const GURL& origin() const { return origin_; }
  FileSystemType type() const { return type_; }

  // TODO(kinuko): this must be std::string.
  const FilePath& path() const { return path_; }

  // For isolated filesystem.
  const std::string& filesystem_id() const { return filesystem_id_; }

  std::string spec() const;

  // Returns a new FileSystemURL with the given path.
  // This doesn't change the calling instance's data.
  FileSystemURL WithPath(const FilePath& path) const;

  bool operator==(const FileSystemURL& that) const;

 private:
  void MayCrackIsolatedPath();

  GURL origin_;
  FileSystemType type_;
  FilePath path_;
  std::string filesystem_id_;  // For isolated filesystem.

  bool is_valid_;
};

}  // namespace fileapi

#endif  // WEBKIT_FILEAPI_FILE_SYSTEM_URL_H_