HTML Standard Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/2352

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
Index: source
===================================================================
--- source	(revision 2351)
+++ source	(revision 2352)
@@ -39778,8 +39778,8 @@
   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);
 
@@ -39876,33 +39876,51 @@
 
   </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>
+  being the zeroth entry.</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>
+  <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>
@@ -39939,31 +39957,12 @@
    or equivalent, or if there were network errors, or if the user
    canceled the download, then abort these steps.</p></li>
 
-   <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>
 
-    <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>
-
   </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
@@ -39978,6 +39977,11 @@
   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

|