Closed Bug 1067232 Opened 10 years ago Closed 10 years ago

[SMS] Avoid to make a private memory copy for file based blob

Categories

(Firefox OS Graveyard :: Gaia::SMS, defect)

ARM
Gonk (Firefox OS)
defect
Not set
major

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: steveck, Assigned: steveck)

References

Details

After bug 1059233, we will create a private copy for data return from picker to avoid any possible crash by accessing the memory-based blob. But there is no need to make a copy for file-based blob. We need to specify that only memory-based image blob(cropped image) need to have a copy in message app.
Summary: [SMS] → [SMS] Avoid to make a private memory copy for file based blob
Oleg, thanks for the reminder in bug 1059233. It's one line changes in compose.js but I have no proper way for the test case. Do you have a good idea to create a file-based blob for assertion?
Flags: needinfo?(azasypkin)
It's hard to say without seeing actual test :) But maybe we can use "test/unit/assets_helper.js" for this and tune "loadFileBlob" [1] a bit, like:

.....
// Or maybe directly arraybuffer, but I don't know how to get correct type for File then
xhr.responseType = 'blob';
xhr.onload = function() {
  var fileReader = new FileReader();
  fileReader.onload = function() {
    resolve(new File([this.result], filePath, {
      type: xhr.response.type
    }));
  };
  fileReader.readAsArrayBuffer(xhr.response);
};
....

Or maybe just dumb File constructor will work (new File([], ....)), depends on test case

[1] https://github.com/mozilla-b2g/gaia/blob/3cb88f9f55725a3be107127cf6936bc7ffd9452a/apps/sms/test/unit/assets_helper.js#L53
Flags: needinfo?(azasypkin)
This bug is now invalid :)
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.