示例#1
0
already_AddRefed<IDBOpenDBRequest>
IDBFactory::Open(JSContext* aCx,
                 const nsAString& aName,
                 uint64_t aVersion,
                 ErrorResult& aRv)
{
    return OpenInternal(aCx,
                        /* aPrincipal */ nullptr,
                        aName,
                        Optional<uint64_t>(aVersion),
                        Optional<StorageType>(),
                        /* aDeleting */ false,
                        aRv);
}
示例#2
0
already_AddRefed<IDBOpenDBRequest>
IDBFactory::Open(JSContext* aCx,
                 const nsAString& aName,
                 const IDBOpenDBOptions& aOptions,
                 ErrorResult& aRv)
{
    return OpenInternal(aCx,
                        /* aPrincipal */ nullptr,
                        aName,
                        aOptions.mVersion,
                        aOptions.mStorage,
                        /* aDeleting */ false,
                        aRv);
}
示例#3
0
already_AddRefed<IDBOpenDBRequest> IDBFactory::OpenForPrincipal(
    JSContext* aCx, nsIPrincipal* aPrincipal, const nsAString& aName,
    uint64_t aVersion, SystemCallerGuarantee aGuarantee, ErrorResult& aRv) {
  MOZ_ASSERT(aPrincipal);
  if (!NS_IsMainThread()) {
    MOZ_CRASH(
        "Figure out security checks for workers!  What's this aPrincipal "
        "we have on a worker thread?");
  }

  return OpenInternal(aCx, aPrincipal, aName, Optional<uint64_t>(aVersion),
                      Optional<StorageType>(),
                      /* aDeleting */ false, aGuarantee, aRv);
}
示例#4
0
bool MiniMaid::Open()
{
	if( OpenInternal(MINIMAID_VENDOR_ID, MINIMAID_PRODUCT_ID) )
	{
		m_bInitialized = true;
		return true;
	}
	else
	{
		m_bInitialized = false;
		LOG->Warn("Could not open a connection to the MiniMaid device!");
	}

	return false;
}
示例#5
0
already_AddRefed<IDBOpenDBRequest>
IDBFactory::DeleteDatabase(JSContext* aCx,
                           const nsAString& aName,
                           const IDBOpenDBOptions& aOptions,
                           CallerType aCallerType,
                           ErrorResult& aRv)
{
  return OpenInternal(aCx,
                      /* aPrincipal */ nullptr,
                      aName,
                      Optional<uint64_t>(),
                      aOptions.mStorage,
                      /* aDeleting */ true,
                      aCallerType,
                      aRv);
}
示例#6
0
already_AddRefed<IDBOpenDBRequest>
IDBFactory::DeleteForPrincipal(nsIPrincipal* aPrincipal,
                               const nsAString& aName,
                               const IDBOpenDBOptions& aOptions,
                               ErrorResult& aRv)
{
  MOZ_ASSERT(aPrincipal);
  if (!NS_IsMainThread()) {
    MOZ_CRASH("Figure out security checks for workers!");
  }
  MOZ_ASSERT(nsContentUtils::IsCallerChrome());

  return OpenInternal(aPrincipal,
                      aName,
                      Optional<uint64_t>(),
                      aOptions.mStorage,
                      /* aDeleting */ true,
                      aRv);
}
示例#7
0
already_AddRefed<IDBOpenDBRequest>
IDBFactory::OpenForPrincipal(JSContext* aCx,
                             nsIPrincipal* aPrincipal,
                             const nsAString& aName,
                             uint64_t aVersion,
                             ErrorResult& aRv)
{
    MOZ_ASSERT(aPrincipal);
    if (!NS_IsMainThread()) {
        MOZ_CRASH("Figure out security checks for workers!");
    }
    MOZ_ASSERT(nsContentUtils::IsCallerChrome());

    return OpenInternal(aCx,
                        aPrincipal,
                        aName,
                        Optional<uint64_t>(aVersion),
                        Optional<StorageType>(),
                        /* aDeleting */ false,
                        aRv);
}
示例#8
0
already_AddRefed<IDBOpenDBRequest>
IDBFactory::Open(JSContext* aCx,
                 const nsAString& aName,
                 const IDBOpenDBOptions& aOptions,
                 CallerType aCallerType,
                 ErrorResult& aRv)
{
  if (!IsChrome() &&
      aOptions.mStorage.WasPassed()) {

    if (mWindow && mWindow->GetExtantDoc()) {
      mWindow->GetExtantDoc()->WarnOnceAbout(nsIDocument::eIDBOpenDBOptions_StorageType);
    } else if (!NS_IsMainThread()) {
      // The method below reports on the main thread too, so we need to make sure we're on a worker.
      // Workers don't have a WarnOnceAbout mechanism, so this will be reported every time.
      WorkerPrivate::ReportErrorToConsole("IDBOpenDBOptions_StorageType");
    }

    bool ignore = false;
    // Ignore internal usage on about: pages.
    if (NS_IsMainThread()) {
      nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(*mPrincipalInfo);
      if (principal) {
        nsCOMPtr<nsIURI> uri;
        nsresult rv = principal->GetURI(getter_AddRefs(uri));
        if (NS_SUCCEEDED(rv) && uri) {
          bool isAbout;
          rv = uri->SchemeIs("about", &isAbout);
          if (NS_SUCCEEDED(rv) && isAbout) {
            ignore = true;
          }
        }
      }
    }

    if (!ignore) {
      switch (aOptions.mStorage.Value()) {
        case StorageType::Persistent: {
          Telemetry::ScalarAdd(Telemetry::ScalarID::IDB_TYPE_PERSISTENT_COUNT, 1);
          break;
        }

        case StorageType::Temporary: {
          Telemetry::ScalarAdd(Telemetry::ScalarID::IDB_TYPE_TEMPORARY_COUNT, 1);
          break;
        }

        case StorageType::Default:
        case StorageType::EndGuard_:
          break;

        default:
          MOZ_CRASH("Invalid storage type!");
      }
    }
  }

  return OpenInternal(aCx,
                      /* aPrincipal */ nullptr,
                      aName,
                      aOptions.mVersion,
                      aOptions.mStorage,
                      /* aDeleting */ false,
                      aCallerType,
                      aRv);
}
示例#9
0
bool File::Open(const String& fileName, FileMode mode)
{
    return OpenInternal(fileName, mode);
}
示例#10
0
bool CFileMap::Create(LPCTSTR path, DWORD size)
{
	return OpenInternal(path, GENERIC_READ | GENERIC_WRITE, CREATE_ALWAYS, PAGE_READWRITE, FILE_MAP_WRITE, size);
}