OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 { | 542 { |
543 append(GenerateFreshDenseArrayTag); | 543 append(GenerateFreshDenseArrayTag); |
544 doWriteUint32(length); | 544 doWriteUint32(length); |
545 } | 545 } |
546 | 546 |
547 v8::Isolate* getIsolate() { return m_isolate; } | 547 v8::Isolate* getIsolate() { return m_isolate; } |
548 | 548 |
549 private: | 549 private: |
550 void doWriteFile(const File& file) | 550 void doWriteFile(const File& file) |
551 { | 551 { |
552 doWriteWebCoreString(file.path()); | 552 doWriteWebCoreString(file.hasBackingFile() ? file.path() : ""); |
| 553 doWriteWebCoreString(file.name()); |
| 554 doWriteWebCoreString(file.webkitRelativePath()); |
553 doWriteWebCoreString(file.uuid()); | 555 doWriteWebCoreString(file.uuid()); |
554 doWriteWebCoreString(file.type()); | 556 doWriteWebCoreString(file.type()); |
| 557 |
| 558 // FIXME don't use 4 bytes to encode a flag. |
| 559 if (file.hasValidSnapshotMetadata()) { |
| 560 doWriteUint32(static_cast<uint8_t>(1)); |
| 561 |
| 562 long long size; |
| 563 double lastModified; |
| 564 file.captureSnapshot(size, lastModified); |
| 565 doWriteUint64(static_cast<uint64_t>(size)); |
| 566 doWriteNumber(lastModified); |
| 567 } else { |
| 568 append(static_cast<uint8_t>(0)); |
| 569 } |
555 } | 570 } |
556 | 571 |
557 void doWriteArrayBuffer(const ArrayBuffer& arrayBuffer) | 572 void doWriteArrayBuffer(const ArrayBuffer& arrayBuffer) |
558 { | 573 { |
559 uint32_t byteLength = arrayBuffer.byteLength(); | 574 uint32_t byteLength = arrayBuffer.byteLength(); |
560 doWriteUint32(byteLength); | 575 doWriteUint32(byteLength); |
561 append(static_cast<const uint8_t*>(arrayBuffer.data()), byteLength); | 576 append(static_cast<const uint8_t*>(arrayBuffer.data()), byteLength); |
562 } | 577 } |
563 | 578 |
564 void doWriteString(const char* data, int length) | 579 void doWriteString(const char* data, int length) |
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 } | 1894 } |
1880 *value = toV8(fileList.release(), v8::Handle<v8::Object>(), m_isolate); | 1895 *value = toV8(fileList.release(), v8::Handle<v8::Object>(), m_isolate); |
1881 return true; | 1896 return true; |
1882 } | 1897 } |
1883 | 1898 |
1884 PassRefPtr<File> doReadFileHelper() | 1899 PassRefPtr<File> doReadFileHelper() |
1885 { | 1900 { |
1886 if (m_version < 3) | 1901 if (m_version < 3) |
1887 return 0; | 1902 return 0; |
1888 String path; | 1903 String path; |
| 1904 String name; |
| 1905 String relativePath; |
1889 String uuid; | 1906 String uuid; |
1890 String type; | 1907 String type; |
| 1908 uint32_t hasSnapshot = 0; |
| 1909 uint64_t size = 0; |
| 1910 double lastModified = 0; |
1891 if (!readWebCoreString(&path)) | 1911 if (!readWebCoreString(&path)) |
1892 return 0; | 1912 return 0; |
| 1913 if (m_version >= 4 && !readWebCoreString(&name)) |
| 1914 return 0; |
| 1915 if (m_version >= 4 && !readWebCoreString(&relativePath)) |
| 1916 return 0; |
1893 if (!readWebCoreString(&uuid)) | 1917 if (!readWebCoreString(&uuid)) |
1894 return 0; | 1918 return 0; |
1895 if (!readWebCoreString(&type)) | 1919 if (!readWebCoreString(&type)) |
1896 return 0; | 1920 return 0; |
1897 return File::create(path, getOrCreateBlobDataHandle(uuid, type)); | 1921 if (m_version >= 4 && !doReadUint32(&hasSnapshot)) |
| 1922 return 0; |
| 1923 if (hasSnapshot) { |
| 1924 if (!doReadUint64(&size)) |
| 1925 return 0; |
| 1926 if (!doReadNumber(&lastModified)) |
| 1927 return 0; |
| 1928 } |
| 1929 return File::create(path, name, relativePath, hasSnapshot > 0, size, las
tModified, getOrCreateBlobDataHandle(uuid, type)); |
1898 } | 1930 } |
1899 | 1931 |
1900 template<class T> | 1932 template<class T> |
1901 bool doReadUintHelper(T* value) | 1933 bool doReadUintHelper(T* value) |
1902 { | 1934 { |
1903 *value = 0; | 1935 *value = 0; |
1904 uint8_t currentByte; | 1936 uint8_t currentByte; |
1905 int shift = 0; | 1937 int shift = 0; |
1906 do { | 1938 do { |
1907 if (m_position >= m_length) | 1939 if (m_position >= m_length) |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2466 // If the allocated memory was not registered before, then this class is lik
ely | 2498 // If the allocated memory was not registered before, then this class is lik
ely |
2467 // used in a context other then Worker's onmessage environment and the prese
nce of | 2499 // used in a context other then Worker's onmessage environment and the prese
nce of |
2468 // current v8 context is not guaranteed. Avoid calling v8 then. | 2500 // current v8 context is not guaranteed. Avoid calling v8 then. |
2469 if (m_externallyAllocatedMemory) { | 2501 if (m_externallyAllocatedMemory) { |
2470 ASSERT(v8::Isolate::GetCurrent()); | 2502 ASSERT(v8::Isolate::GetCurrent()); |
2471 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); | 2503 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_exte
rnallyAllocatedMemory); |
2472 } | 2504 } |
2473 } | 2505 } |
2474 | 2506 |
2475 } // namespace WebCore | 2507 } // namespace WebCore |
OLD | NEW |