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

Side by Side Diff: trunk/src/ui/base/resource/data_pack.cc

Issue 189793002: Revert 255397 "Fill out the rest of the StringPiece functions fo..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 | « trunk/src/net/websockets/websocket_basic_handshake_stream.cc ('k') | 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 // 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 #include "ui/base/resource/data_pack.h" 5 #include "ui/base/resource/data_pack.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/memory_mapped_file.h" 10 #include "base/files/memory_mapped_file.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 const DataPackEntry* target = reinterpret_cast<const DataPackEntry*>( 183 const DataPackEntry* target = reinterpret_cast<const DataPackEntry*>(
184 bsearch(&resource_id, mmap_->data() + kHeaderLength, resource_count_, 184 bsearch(&resource_id, mmap_->data() + kHeaderLength, resource_count_,
185 sizeof(DataPackEntry), DataPackEntry::CompareById)); 185 sizeof(DataPackEntry), DataPackEntry::CompareById));
186 if (!target) { 186 if (!target) {
187 return false; 187 return false;
188 } 188 }
189 189
190 const DataPackEntry* next_entry = target + 1; 190 const DataPackEntry* next_entry = target + 1;
191 size_t length = next_entry->file_offset - target->file_offset; 191 size_t length = next_entry->file_offset - target->file_offset;
192 192
193 data->set(reinterpret_cast<const char*>(mmap_->data() + target->file_offset), 193 data->set(mmap_->data() + target->file_offset, length);
194 length);
195 return true; 194 return true;
196 } 195 }
197 196
198 base::RefCountedStaticMemory* DataPack::GetStaticMemory( 197 base::RefCountedStaticMemory* DataPack::GetStaticMemory(
199 uint16 resource_id) const { 198 uint16 resource_id) const {
200 base::StringPiece piece; 199 base::StringPiece piece;
201 if (!GetStringPiece(resource_id, &piece)) 200 if (!GetStringPiece(resource_id, &piece))
202 return NULL; 201 return NULL;
203 202
204 return new base::RefCountedStaticMemory(piece.data(), piece.length()); 203 return new base::RefCountedStaticMemory(piece.data(), piece.length());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 return false; 296 return false;
298 } 297 }
299 } 298 }
300 299
301 base::CloseFile(file); 300 base::CloseFile(file);
302 301
303 return true; 302 return true;
304 } 303 }
305 304
306 } // namespace ui 305 } // namespace ui
OLDNEW
« no previous file with comments | « trunk/src/net/websockets/websocket_basic_handshake_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698