HTML Standard Tracker

Filter

File a bug

SVNBugCommentTime (UTC)
2352[Gecko] [Webkit] [Google Gears] Appcache: Change the approach used for the dynamic entries API so that it makes more sense in a threaded environment.2008-10-18 01:28
@@ -39771,22 +39771,22 @@ style/default.css</pre>
   const unsigned short <span title="dom-appcache-DOWNLOADING">DOWNLOADING</span> = 3;
   const unsigned short <span title="dom-appcache-UPDATEREADY">UPDATEREADY</span> = 4;
   const unsigned short <span title="dom-appcache-OBSOLETE">OBSOLETE</span> = 5;
   readonly attribute unsigned short <span title="dom-appcache-status">status</span>;
 
   // updates
   void <span title="dom-appcache-update">update</span>();
   void <span title="dom-appcache-swapCache">swapCache</span>();
 
   // dynamic entries
-  readonly attribute unsigned long <span title="dom-appcache-length">length</span>;
-  DOMString <span title="dom-appcache-item">item</span>(in unsigned long index);
+  readonly attribute <span>DOMStringList</span> <span title="dom-appcache-items">items</span>;
+  boolean <span title="dom-appcache-hasItem">hasItem</span>(in DOMString url);
   void <span title="dom-appcache-add">add</span>(in DOMString url);
   void <span title="dom-appcache-remove">remove</span>(in DOMString url);
 
   // events
            attribute <span>EventListener</span> <span title="handler-appcache-onchecking">onchecking</span>;
            attribute <span>EventListener</span> <span title="handler-appcache-onerror">onerror</span>;
            attribute <span>EventListener</span> <span title="handler-appcache-onnoupdate">onnoupdate</span>;
            attribute <span>EventListener</span> <span title="handler-appcache-ondownloading">ondownloading</span>;
            attribute <span>EventListener</span> <span title="handler-appcache-onprogress">onprogress</span>;
            attribute <span>EventListener</span> <span title="handler-appcache-onupdateready">onupdateready</span>;
@@ -39869,46 +39869,64 @@ style/default.css</pre>
    <dt><dfn title="dom-appcache-OBSOLETE"><code>OBSOLETE</code></dfn>
    (numeric value 5)</dt>
 
    <dd><p>The <code>ApplicationCache</code> object is associated with
    an <span>application cache</span> whose group is in the
    <i>obsolete</i> <span title="concept-appcache-lifecycle">lifecycle
    status</span>.</p></dd>
 
   </dl>
 
-  <p>The <dfn title="dom-appcache-length"><code>length</code></dfn>
-  attribute must return the number of <span
-  title="concept-appcache-dynamic">dynamic entries</span> in the
-  <span>application cache</span> with which the
-  <code>ApplicationCache</code> object is associated, if any, and zero
-  if the object is not associated with any application cache.</p>
+  <hr>
 
   <p>The <span title="concept-appcache-dynamic">dynamic entries</span>
   in the <span>application cache</span> are ordered in the same order
   as they were added to the cache by the <code
   title="dom-appcache-add">add()</code> method, with the oldest entry
-  being the zeroth entry, and the most recently added entry having the
-  index <span><code
-  title="dom-appcache-length">length</code>-1</span>.</p>
-
-  <p>The <dfn title="dom-appcache-item"><code>item(<var
-  title="">index</var>)</code></dfn> method must return the
-  <span>absolute URL</span> of the <span
-  title="concept-appcache-dynamic">dynamic entry</span> with index
-  <var title="">index</var> from the <span>application cache</span>,
-  if one is associated with the <code>ApplicationCache</code>
-  object. If the object is not associated with any application cache,
-  or if the <var title="">index</var> argument is lower than zero or
-  greater than <span><code
-  title="dom-appcache-length">length</code>-1</span>, the method must
-  instead raise an <code>INDEX_SIZE_ERR</code> exception.</p>
+  being the zeroth entry.</p>
+
+  <p>The <dfn title="dom-appcache-items"><code>items</code></dfn> DOM
+  attribute must return a new <code>DOMStringList</code> object. If
+  the <code>ApplicationCache</code> object has an associated
+  <span>application cache</span> with one or more <span
+  title="concept-appcache-dynamic">dynamic entries</span>, then the
+  <code>DOMStringList</code> object's items must be the <span
+  title="absolute URL">absolute URLs</span> of the <span
+  title="concept-appcache-dynamic">dynamic entries</span> in that
+  <span>application cache</span>, in order; otherwise, the object must
+  have no entries.</p>
+
+  <p>The <dfn title="dom-appcache-hasItem"><code>hasItem(<var
+  title="">url</var>)</code></dfn> method must run the following
+  steps:</p>
+
+  <ol>
+
+   <li><p>If the <code>ApplicationCache</code> object is not
+   associated with any application cache, then raise an
+   <code>INVALID_STATE_ERR</code> exception and abort these
+   steps.</p></li>
+
+   <li><p><span title="resolve a URL">Resolve</span> the <var
+   title="">url</var> argument. If this fails, raise a
+   <code>SYNTAX_ERR</code> exception and abort these steps.</p></li>
+
+   <li><p>If there is already a resource in in the <span>application
+   cache</span> with which the <code>ApplicationCache</code> object is
+   associated that has the address <var title="">url</var>, and that
+   entry is categorized as a <span
+   title="concept-appcache-dynamic">dynamic entry</span>, then return
+   true.</p></li>
+
+   <li><p>Otherwise, return false.</p></li>
+
+  </ol>
 
   <p>The <dfn title="dom-appcache-add"><code>add(<var
   title="">url</var>)</code></dfn> method must run the following
   steps:</p>
 
   <ol>
 
    <li><p>If the <code>ApplicationCache</code> object is not
    associated with any application cache, then raise an
    <code>INVALID_STATE_ERR</code> exception and abort these
@@ -39932,59 +39950,45 @@ style/default.css</pre>
 
    <li><p>Return, but do not abort these steps.</p></li>
 
    <li><p><span>Fetch</span> the resource referenced by <var
    title="">url</var>.</p></li>
 
    <li><p>If this results in a redirect, or a 4xx or 5xx status code
    or equivalent, or if there were network errors, or if the user
    canceled the download, then abort these steps.</p></li>
 
-   <li>
-
-    <p>Wait for there to be no running scripts, or at least no running
-    scripts that can reach an <code>ApplicationCache</code> object
-    associated with the <span>application cache</span> with which this
-    <code>ApplicationCache</code> object is associated.</p>
-
-    <p>Add the fetched resource to the <span>application cache</span>
-    and categorize it as a <span
-    title="concept-appcache-dynamic">dynamic entry</span> before
-    letting any such scripts resume.</p>
-  
-   </li>
+   <li><p>Add the fetched resource to the <span>application
+   cache</span> and categorize it as a <span
+   title="concept-appcache-dynamic">dynamic entry</span>.</p></li>
 
   </ol>
 
-  <p class="XXX">We can make the add() API more usable
-  (i.e. make it possible to detect progress and distinguish success
-  from errors without polling and timeouts) if we have the method
-  return an object that is a target of Progress Events, much like the
-  <a
-  href="http://dev.w3.org/cvsweb/~checkout~/2006/webapi/XMLHttpRequest-2/Overview.html?content-type=text/html;%20charset=utf-8#xmlhttprequesteventtarget-interface">XMLHttpRequestEventTarget</a>
-  interface. This would also make this far more complex to spec and
-  implement.</p>
-
   <p>The <dfn title="dom-appcache-remove"><code>remove(<var
   title="">url</var>)</code></dfn> method must <span title="resolve a
   url">resolve</span> the <var title="">url</var> argument and, if
   that is successful, remove the <span
   title="concept-appcache-dynamic">dynamic entry</span> categorization
   of any entry whose address is the resulting <span>absolute
   URL</span> in the <span>application cache</span> with which the
   <code>ApplicationCache</code> object is associated. If this removes
   the last categorization of an entry in that cache, then the entry
   must be removed entirely (such that if it is re-added, it will be
   loaded from the network again). If the <code>ApplicationCache</code>
   object is not associated with any application cache, then the method
   must raise an <code>INVALID_STATE_ERR</code> exception instead.</p>
 
+  <p class="warning">Authors should bear in mind that multiple scripts
+  could be simultaneously modifying the same application cache.</p>
+
+  <hr>
+
   <p>If the <dfn
   title="dom-appcache-update"><code>update()</code></dfn> method is
   invoked, the user agent must invoke the <span>application cache
   update process</span>, in the background, for the <span>application
   cache</span> with which the <code>ApplicationCache</code> object is
   associated, but with no <span>browsing context</span>. If there is
   no such application cache, then the method must raise an
   <code>INVALID_STATE_ERR</code> exception instead.</p>
 
   <p>If the <dfn

|