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