Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: chrome/browser/resources/file_manager/js/metadata_provider.js

Issue 8538009: Cleaning up and updating mock_chrome.js (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/mock_chrome.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @param {string} opt_workerPath path to the worker source JS file. 6 * @param {string} opt_workerPath path to the worker source JS file.
7 */ 7 */
8 function MetadataProvider(opt_workerPath) { 8 function MetadataProvider(opt_workerPath) {
9 this.cache_ = {}; 9 this.cache_ = {};
10 10
11 // Pass all URLs to the metadata reader until we have a correct filter. 11 // Pass all URLs to the metadata reader until we have a correct filter.
12 this.urlFilter = /.*/; 12 this.urlFilter = /.*/;
13 13
14 this.dispatcher_ = new Worker(opt_workerPath || 14 if (!opt_workerPath) {
15 document.location.origin + '/js/metadata_dispatcher.js'); 15 var path = document.location.pathname;
16 opt_workerPath = path.substring(0, path.lastIndexOf('/') + 1) +
17 'js/metadata_dispatcher.js';
18 }
19
20 this.dispatcher_ = new Worker(opt_workerPath);
16 this.dispatcher_.onmessage = this.onMessage_.bind(this); 21 this.dispatcher_.onmessage = this.onMessage_.bind(this);
17 this.dispatcher_.postMessage({verb: 'init'}); 22 this.dispatcher_.postMessage({verb: 'init'});
18 // Initialization is not complete until the Worker sends back the 23 // Initialization is not complete until the Worker sends back the
19 // 'initialized' message. See below. 24 // 'initialized' message. See below.
20 } 25 }
21 26
22 MetadataProvider.prototype.fetch = function(url, callback) { 27 MetadataProvider.prototype.fetch = function(url, callback) {
23 var cacheValue = this.cache_[url]; 28 var cacheValue = this.cache_[url];
24 29
25 if (!cacheValue) { 30 if (!cacheValue) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 }; 105 };
101 106
102 MetadataProvider.prototype.onError_ = function(url, step, error, metadata) { 107 MetadataProvider.prototype.onError_ = function(url, step, error, metadata) {
103 console.warn('metadata: ' + url + ': ' + step + ': ' + error); 108 console.warn('metadata: ' + url + ': ' + step + ': ' + error);
104 this.onResult_(url, metadata || {}); 109 this.onResult_(url, metadata || {});
105 }; 110 };
106 111
107 MetadataProvider.prototype.onLog_ = function(arglist) { 112 MetadataProvider.prototype.onLog_ = function(arglist) {
108 console.log.apply(console, ['metadata:'].concat(arglist)); 113 console.log.apply(console, ['metadata:'].concat(arglist));
109 }; 114 };
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/mock_chrome.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698