dom/filesystem/FileSystemBase.cpp

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:dec337d43b66
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #include "mozilla/dom/FileSystemBase.h"
8
9 #include "DeviceStorageFileSystem.h"
10 #include "nsCharSeparatedTokenizer.h"
11
12 namespace mozilla {
13 namespace dom {
14
15 // static
16 already_AddRefed<FileSystemBase>
17 FileSystemBase::FromString(const nsAString& aString)
18 {
19 if (StringBeginsWith(aString, NS_LITERAL_STRING("devicestorage-"))) {
20 // The string representation of devicestorage file system is of the format:
21 // devicestorage-StorageType-StorageName
22
23 nsCharSeparatedTokenizer tokenizer(aString, char16_t('-'));
24 tokenizer.nextToken();
25
26 nsString storageType;
27 if (tokenizer.hasMoreTokens()) {
28 storageType = tokenizer.nextToken();
29 }
30
31 nsString storageName;
32 if (tokenizer.hasMoreTokens()) {
33 storageName = tokenizer.nextToken();
34 }
35
36 nsRefPtr<DeviceStorageFileSystem> f =
37 new DeviceStorageFileSystem(storageType, storageName);
38 return f.forget();
39 }
40 return nullptr;
41 }
42
43 FileSystemBase::FileSystemBase()
44 : mShutdown(false)
45 , mIsTesting(false)
46 {
47 }
48
49 FileSystemBase::~FileSystemBase()
50 {
51 }
52
53 void
54 FileSystemBase::Shutdown()
55 {
56 mShutdown = true;
57 }
58
59 nsPIDOMWindow*
60 FileSystemBase::GetWindow() const
61 {
62 return nullptr;
63 }
64
65 bool
66 FileSystemBase::IsSafeFile(nsIFile* aFile) const
67 {
68 return false;
69 }
70
71 bool
72 FileSystemBase::IsSafeDirectory(Directory* aDir) const
73 {
74 return false;
75 }
76
77 } // namespace dom
78 } // namespace mozilla

mercurial