| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 #if OS(ANDROID) | 103 #if OS(ANDROID) |
| 104 if (url.protocolIs("content")) | 104 if (url.protocolIs("content")) |
| 105 return true; | 105 return true; |
| 106 #endif | 106 #endif |
| 107 return false; | 107 return false; |
| 108 } | 108 } |
| 109 | 109 |
| 110 void MHTMLArchive::generateMHTMLHeader(const String& boundary, | 110 void MHTMLArchive::generateMHTMLHeader(const String& boundary, |
| 111 const String& title, | 111 const String& title, |
| 112 const String& mimeType, | 112 const String& mimeType, |
| 113 SharedBuffer& outputBuffer) { | 113 Vector<char>& outputBuffer) { |
| 114 ASSERT(!boundary.isEmpty()); | 114 ASSERT(!boundary.isEmpty()); |
| 115 ASSERT(!mimeType.isEmpty()); | 115 ASSERT(!mimeType.isEmpty()); |
| 116 | 116 |
| 117 DateComponents now; | 117 DateComponents now; |
| 118 now.setMillisecondsSinceEpochForDateTime(currentTimeMS()); | 118 now.setMillisecondsSinceEpochForDateTime(currentTimeMS()); |
| 119 // TODO(lukasza): Passing individual date/time components seems fragile. | 119 // TODO(lukasza): Passing individual date/time components seems fragile. |
| 120 String dateString = makeRFC2822DateString( | 120 String dateString = makeRFC2822DateString( |
| 121 now.weekDay(), now.monthDay(), now.month(), now.fullYear(), now.hour(), | 121 now.weekDay(), now.monthDay(), now.month(), now.fullYear(), now.hour(), |
| 122 now.minute(), now.second(), 0); | 122 now.minute(), now.second(), 0); |
| 123 | 123 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 142 ASSERT(stringBuilder.toString().containsOnlyASCII()); | 142 ASSERT(stringBuilder.toString().containsOnlyASCII()); |
| 143 CString asciiString = stringBuilder.toString().utf8(); | 143 CString asciiString = stringBuilder.toString().utf8(); |
| 144 | 144 |
| 145 outputBuffer.append(asciiString.data(), asciiString.length()); | 145 outputBuffer.append(asciiString.data(), asciiString.length()); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void MHTMLArchive::generateMHTMLPart(const String& boundary, | 148 void MHTMLArchive::generateMHTMLPart(const String& boundary, |
| 149 const String& contentID, | 149 const String& contentID, |
| 150 EncodingPolicy encodingPolicy, | 150 EncodingPolicy encodingPolicy, |
| 151 const SerializedResource& resource, | 151 const SerializedResource& resource, |
| 152 SharedBuffer& outputBuffer) { | 152 Vector<char>& outputBuffer) { |
| 153 ASSERT(!boundary.isEmpty()); | 153 ASSERT(!boundary.isEmpty()); |
| 154 ASSERT(contentID.isEmpty() || contentID[0] == '<'); | 154 ASSERT(contentID.isEmpty() || contentID[0] == '<'); |
| 155 | 155 |
| 156 StringBuilder stringBuilder; | 156 StringBuilder stringBuilder; |
| 157 stringBuilder.append("--"); | 157 stringBuilder.append("--"); |
| 158 stringBuilder.append(boundary); | 158 stringBuilder.append(boundary); |
| 159 stringBuilder.append("\r\n"); | 159 stringBuilder.append("\r\n"); |
| 160 | 160 |
| 161 stringBuilder.append("Content-Type: "); | 161 stringBuilder.append("Content-Type: "); |
| 162 stringBuilder.append(resource.mimeType); | 162 stringBuilder.append(resource.mimeType); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 std::min(encodedDataLength - index, maximumLineLength); | 222 std::min(encodedDataLength - index, maximumLineLength); |
| 223 outputBuffer.append(encodedData.data() + index, lineLength); | 223 outputBuffer.append(encodedData.data() + index, lineLength); |
| 224 outputBuffer.append("\r\n", 2u); | 224 outputBuffer.append("\r\n", 2u); |
| 225 index += maximumLineLength; | 225 index += maximumLineLength; |
| 226 } while (index < encodedDataLength); | 226 } while (index < encodedDataLength); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 void MHTMLArchive::generateMHTMLFooter(const String& boundary, | 231 void MHTMLArchive::generateMHTMLFooter(const String& boundary, |
| 232 SharedBuffer& outputBuffer) { | 232 Vector<char>& outputBuffer) { |
| 233 ASSERT(!boundary.isEmpty()); | 233 ASSERT(!boundary.isEmpty()); |
| 234 CString asciiString = String("--" + boundary + "--\r\n").utf8(); | 234 CString asciiString = String("--" + boundary + "--\r\n").utf8(); |
| 235 outputBuffer.append(asciiString.data(), asciiString.length()); | 235 outputBuffer.append(asciiString.data(), asciiString.length()); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void MHTMLArchive::setMainResource(ArchiveResource* mainResource) { | 238 void MHTMLArchive::setMainResource(ArchiveResource* mainResource) { |
| 239 m_mainResource = mainResource; | 239 m_mainResource = mainResource; |
| 240 } | 240 } |
| 241 | 241 |
| 242 void MHTMLArchive::addSubresource(ArchiveResource* resource) { | 242 void MHTMLArchive::addSubresource(ArchiveResource* resource) { |
| 243 const KURL& url = resource->url(); | 243 const KURL& url = resource->url(); |
| 244 m_subresources.set(url, resource); | 244 m_subresources.set(url, resource); |
| 245 KURL cidURI = MHTMLParser::convertContentIDToURI(resource->contentID()); | 245 KURL cidURI = MHTMLParser::convertContentIDToURI(resource->contentID()); |
| 246 if (cidURI.isValid()) | 246 if (cidURI.isValid()) |
| 247 m_subresources.set(cidURI, resource); | 247 m_subresources.set(cidURI, resource); |
| 248 } | 248 } |
| 249 | 249 |
| 250 ArchiveResource* MHTMLArchive::subresourceForURL(const KURL& url) const { | 250 ArchiveResource* MHTMLArchive::subresourceForURL(const KURL& url) const { |
| 251 return m_subresources.get(url.getString()); | 251 return m_subresources.get(url.getString()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 DEFINE_TRACE(MHTMLArchive) { | 254 DEFINE_TRACE(MHTMLArchive) { |
| 255 visitor->trace(m_mainResource); | 255 visitor->trace(m_mainResource); |
| 256 visitor->trace(m_subresources); | 256 visitor->trace(m_subresources); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace blink | 259 } // namespace blink |
| OLD | NEW |