/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIURI;
interface nsILoadContextInfo;
interface nsICacheEntryOpenCallback;

%{C++
  #define PACKAGED_APP_TOKEN "!//"
%}

/**
 * nsIPackagedAppService
 */
[scriptable, builtinclass, uuid(77f9a34d-d082-43f1-9f83-e852d0173cd5)]
interface nsIPackagedAppService : nsISupports
{
  /**
   * @aURI is a URL to a packaged resource
   *   - format:  package_url + PACKAGED_APP_TOKEN + resource_path
   *   - example: http://test.com/path/to/package!//resource.html
   * @aCallback is an object implementing nsICacheEntryOpenCallback
   *   - this is the target of the async result of the operation
   *   - aCallback->OnCacheEntryCheck() is called to verify the entry is valid
   *   - aCallback->OnCacheEntryAvailable() is called with a pointer to the
   *     the cached entry, if one exists, or an error code otherwise
   *   - aCallback is kept alive using an nsCOMPtr until OnCacheEntryAvailable
   *     is called
   * @aInfo is an object used to determine the cache jar this resource goes in.
   *   - usually created by calling GetLoadContextInfo(requestingChannel)
   *
   * Calling this method will either download the package containing the given
   * resource URI, store it in the cache and pass the cache entry to aCallback,
   * or if that resource has already been downloaded it will be served from
   * the cache.
   */
  void requestURI(in nsIURI aURI, in nsILoadContextInfo aInfo, in nsICacheEntryOpenCallback aCallback);
};
