summaryrefslogtreecommitdiffstats
path: root/chrome/browser/file_system/file_system_host_context.h
blob: 592ccd6126fb5fdd3fcd87469a2cfb51d273e27b (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
// Copyright (c) 2010 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 CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_HOST_CONTEXT_H_
#define CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_HOST_CONTEXT_H_

#include "base/file_path.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFileSystem.h"

// This is owned by profile and shared by all the FileSystemDispatcherHost
// that shared by the same profile.
class FileSystemHostContext
    : public base::RefCountedThreadSafe<FileSystemHostContext> {
 public:
  FileSystemHostContext(const FilePath& data_path, bool is_incognito);
  const FilePath& base_path() const { return base_path_; }
  bool is_incognito() const { return is_incognito_; }

  // Returns the root path and name for the file system specified by given
  // |origin_url| and |type|.  Returns true if the file system is available
  // for the profile and |root_path| and |name| are filled successfully.
  bool GetFileSystemRootPath(
      const GURL& origin_url,
      WebKit::WebFileSystem::Type type,
      FilePath* root_path,
      std::string* name) const;

  // Check if the given |path| is in the FileSystem base directory.
  bool CheckValidFileSystemPath(const FilePath& path) const;

  // Returns the storage identifier string for the given |url|.
  static std::string GetStorageIdentifierFromURL(const GURL& url);

  // The FileSystem directory name.
  static const FilePath::CharType kFileSystemDirectory[];

  static const char kPersistentName[];
  static const char kTemporaryName[];

 private:
  const FilePath base_path_;
  const bool is_incognito_;

  DISALLOW_IMPLICIT_CONSTRUCTORS(FileSystemHostContext);
};

#endif  // CHROME_BROWSER_FILE_SYSTEM_FILE_SYSTEM_HOST_CONTEXT_H_