OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 var fileCopyManagerWrapper = null; | |
8 | |
9 /** | 7 /** |
10 * While FileCopyManager is run in the background page, this class is used to | 8 * While FileCopyManager is run in the background page, this class is used to |
11 * communicate with it. | 9 * communicate with it. |
12 * @param {DirectoryEntry} root Root directory entry. | 10 * @param {DirectoryEntry} root Root directory entry. |
13 * @constructor | 11 * @constructor |
14 */ | 12 */ |
15 function FileCopyManagerWrapper(root) { | 13 function FileCopyManagerWrapper(root) { |
16 this.root_ = root; | 14 this.root_ = root; |
17 | 15 |
18 this.status_ = { | 16 this.status_ = { |
(...skipping 23 matching lines...) Expand all Loading... |
42 * Extending cr.EventTarget. | 40 * Extending cr.EventTarget. |
43 */ | 41 */ |
44 FileCopyManagerWrapper.prototype.__proto__ = cr.EventTarget.prototype; | 42 FileCopyManagerWrapper.prototype.__proto__ = cr.EventTarget.prototype; |
45 | 43 |
46 /** | 44 /** |
47 * Create a new instance or get existing instance of FCMW. | 45 * Create a new instance or get existing instance of FCMW. |
48 * @param {DirectoryEntry} root Root directory entry. | 46 * @param {DirectoryEntry} root Root directory entry. |
49 * @return {FileCopyManagerWrapper} A FileCopyManagerWrapper instance. | 47 * @return {FileCopyManagerWrapper} A FileCopyManagerWrapper instance. |
50 */ | 48 */ |
51 FileCopyManagerWrapper.getInstance = function(root) { | 49 FileCopyManagerWrapper.getInstance = function(root) { |
52 if (fileCopyManagerWrapper === null) { | 50 if (!FileCopyManagerWrapper.instance_) |
53 fileCopyManagerWrapper = new FileCopyManagerWrapper(root); | 51 FileCopyManagerWrapper.instance_ = new FileCopyManagerWrapper(root); |
54 } | 52 |
55 return fileCopyManagerWrapper; | 53 return FileCopyManagerWrapper.instance_; |
56 }; | 54 }; |
57 | 55 |
58 /** | 56 /** |
59 * Load background page and call callback with copy manager as an argument. | 57 * Load background page and call callback with copy manager as an argument. |
60 * @param {function} callback Function with FileCopyManager as a parameter. | 58 * @param {function} callback Function with FileCopyManager as a parameter. |
61 * @private | 59 * @private |
62 */ | 60 */ |
63 FileCopyManagerWrapper.prototype.getCopyManagerAsync_ = function(callback) { | 61 FileCopyManagerWrapper.prototype.getCopyManagerAsync_ = function(callback) { |
64 var MAX_RETRIES = 10; | 62 var MAX_RETRIES = 10; |
65 var TIMEOUT = 100; | 63 var TIMEOUT = 100; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 }); | 122 }); |
125 }; | 123 }; |
126 }; | 124 }; |
127 | 125 |
128 FileCopyManagerWrapper.decorateAsyncMethod('requestCancel'); | 126 FileCopyManagerWrapper.decorateAsyncMethod('requestCancel'); |
129 FileCopyManagerWrapper.decorateAsyncMethod('paste'); | 127 FileCopyManagerWrapper.decorateAsyncMethod('paste'); |
130 FileCopyManagerWrapper.decorateAsyncMethod('deleteEntries'); | 128 FileCopyManagerWrapper.decorateAsyncMethod('deleteEntries'); |
131 FileCopyManagerWrapper.decorateAsyncMethod('forceDeleteTask'); | 129 FileCopyManagerWrapper.decorateAsyncMethod('forceDeleteTask'); |
132 FileCopyManagerWrapper.decorateAsyncMethod('cancelDeleteTask'); | 130 FileCopyManagerWrapper.decorateAsyncMethod('cancelDeleteTask'); |
133 FileCopyManagerWrapper.decorateAsyncMethod('zipSelection'); | 131 FileCopyManagerWrapper.decorateAsyncMethod('zipSelection'); |
OLD | NEW |