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

Side by Side Diff: Source/devtools/front_end/bindings/TempFile.js

Issue 661063002: DevTools: wrong event was used as an indicator of finished write operation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 * @this {WebInspector.TempFile} 74 * @this {WebInspector.TempFile}
75 */ 75 */
76 function didCreateWriter(writer) 76 function didCreateWriter(writer)
77 { 77 {
78 /** 78 /**
79 * @this {WebInspector.TempFile} 79 * @this {WebInspector.TempFile}
80 */ 80 */
81 function didTruncate(e) 81 function didTruncate(e)
82 { 82 {
83 this._writer = writer; 83 this._writer = writer;
84 writer.onwrite = null; 84 writer.onwriteend = null;
85 writer.onerror = null; 85 writer.onerror = null;
86 callback(this); 86 callback(this);
87 } 87 }
88 88
89 function onTruncateError(e) 89 function onTruncateError(e)
90 { 90 {
91 WebInspector.console.error("Failed to truncate temp file " + e.code + " : " + e.message); 91 WebInspector.console.error("Failed to truncate temp file " + e.code + " : " + e.message);
92 callback(null); 92 callback(null);
93 } 93 }
94 94
95 if (writer.length) { 95 if (writer.length) {
96 writer.onwrite = didTruncate.bind(this); 96 writer.onwriteend = didTruncate.bind(this);
97 writer.onerror = onTruncateError; 97 writer.onerror = onTruncateError;
98 writer.truncate(0); 98 writer.truncate(0);
99 } else { 99 } else {
100 this._writer = writer; 100 this._writer = writer;
101 callback(this); 101 callback(this);
102 } 102 }
103 } 103 }
104 104
105 function errorHandler(e) 105 function errorHandler(e)
106 { 106 {
(...skipping 14 matching lines...) Expand all
121 WebInspector.TempFile.prototype = { 121 WebInspector.TempFile.prototype = {
122 /** 122 /**
123 * @param {!Array.<string>} strings 123 * @param {!Array.<string>} strings
124 * @param {!function(boolean)} callback 124 * @param {!function(boolean)} callback
125 */ 125 */
126 write: function(strings, callback) 126 write: function(strings, callback)
127 { 127 {
128 var blob = new Blob(strings, {type: 'text/plain'}); 128 var blob = new Blob(strings, {type: 'text/plain'});
129 this._writer.onerror = function(e) 129 this._writer.onerror = function(e)
130 { 130 {
131 WebInspector.console.error("Failed to write into a temp file: " + e. message); 131 WebInspector.console.error("Failed to write into a temp file: " + e. target.error.message);
132 callback(false); 132 callback(false);
133 } 133 }
134 this._writer.onwrite = function(e) 134 this._writer.onwriteend = function(e)
135 { 135 {
136 callback(true); 136 callback(true);
137 } 137 }
138 this._writer.write(blob); 138 this._writer.write(blob);
139 }, 139 },
140 140
141 finishWriting: function() 141 finishWriting: function()
142 { 142 {
143 this._writer = null; 143 this._writer = null;
144 }, 144 },
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 /** 409 /**
410 * @param {!function()} callback 410 * @param {!function()} callback
411 */ 411 */
412 WebInspector.TempFile._ensureTempStorageCleared = function(callback) 412 WebInspector.TempFile._ensureTempStorageCleared = function(callback)
413 { 413 {
414 if (!WebInspector.TempFile._storageCleaner) 414 if (!WebInspector.TempFile._storageCleaner)
415 WebInspector.TempFile._storageCleaner = new WebInspector.TempStorageClea ner(); 415 WebInspector.TempFile._storageCleaner = new WebInspector.TempStorageClea ner();
416 WebInspector.TempFile._storageCleaner.ensureStorageCleared(callback); 416 WebInspector.TempFile._storageCleaner.ensureStorageCleared(callback);
417 } 417 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698