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

Side by Side Diff: chrome/browser/sessions/compress_data_helper.cc

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile (racing with incoming CLs) Created 8 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
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 "chrome/browser/sessions/compress_data_helper.h" 5 #include "chrome/browser/sessions/compress_data_helper.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/pickle.h" 8 #include "base/pickle.h"
9 9
10 #if defined(USE_SYSTEM_LIBBZ2) 10 #if defined(USE_SYSTEM_LIBBZ2)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 if (!written) { 77 if (!written) {
78 // We cannot write any data. Write only the data size (0). The reading part 78 // We cannot write any data. Write only the data size (0). The reading part
79 // will not try to read any data after seeing the size 0. 79 // will not try to read any data after seeing the size 0.
80 pickle->WriteInt(0); 80 pickle->WriteInt(0);
81 } 81 }
82 } 82 }
83 83
84 // static 84 // static
85 bool CompressDataHelper::ReadAndDecompressStringFromPickle(const Pickle& pickle, 85 bool CompressDataHelper::ReadAndDecompressStringFromPickle(const Pickle& pickle,
86 void** iter, 86 PickleIterator* iter,
87 std::string* str) { 87 std::string* str) {
88 // Read the size of the original data. 88 // Read the size of the original data.
89 int original_size = 0; 89 int original_size = 0;
90 if (!pickle.ReadLength(iter, &original_size)) 90 if (!pickle.ReadLength(iter, &original_size))
91 return false; 91 return false;
92 92
93 if (original_size == 0) { 93 if (original_size == 0) {
94 // No data to decompress. 94 // No data to decompress.
95 return true; 95 return true;
96 } 96 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 result = BZ2_bzDecompressEnd(&stream); 132 result = BZ2_bzDecompressEnd(&stream);
133 if (result == BZ_OK) { 133 if (result == BZ_OK) {
134 str->assign(original_data.get(), original_size); 134 str->assign(original_data.get(), original_size);
135 } 135 }
136 } else { 136 } else {
137 BZ2_bzDecompressEnd(&stream); 137 BZ2_bzDecompressEnd(&stream);
138 } 138 }
139 } 139 }
140 return !str->empty(); 140 return !str->empty();
141 } 141 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/compress_data_helper.h ('k') | chrome/browser/sessions/compress_data_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698