dom/filesystem/FileSystemBase.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     7 #include "mozilla/dom/FileSystemBase.h"
     9 #include "DeviceStorageFileSystem.h"
    10 #include "nsCharSeparatedTokenizer.h"
    12 namespace mozilla {
    13 namespace dom {
    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
    23     nsCharSeparatedTokenizer tokenizer(aString, char16_t('-'));
    24     tokenizer.nextToken();
    26     nsString storageType;
    27     if (tokenizer.hasMoreTokens()) {
    28       storageType = tokenizer.nextToken();
    29     }
    31     nsString storageName;
    32     if (tokenizer.hasMoreTokens()) {
    33       storageName = tokenizer.nextToken();
    34     }
    36     nsRefPtr<DeviceStorageFileSystem> f =
    37       new DeviceStorageFileSystem(storageType, storageName);
    38     return f.forget();
    39   }
    40   return nullptr;
    41 }
    43 FileSystemBase::FileSystemBase()
    44   : mShutdown(false)
    45   , mIsTesting(false)
    46 {
    47 }
    49 FileSystemBase::~FileSystemBase()
    50 {
    51 }
    53 void
    54 FileSystemBase::Shutdown()
    55 {
    56   mShutdown = true;
    57 }
    59 nsPIDOMWindow*
    60 FileSystemBase::GetWindow() const
    61 {
    62   return nullptr;
    63 }
    65 bool
    66 FileSystemBase::IsSafeFile(nsIFile* aFile) const
    67 {
    68   return false;
    69 }
    71 bool
    72 FileSystemBase::IsSafeDirectory(Directory* aDir) const
    73 {
    74   return false;
    75 }
    77 } // namespace dom
    78 } // namespace mozilla

mercurial