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

Side by Side Diff: src/platform/update_engine/graph_utils.cc

Issue 1718001: AU: Class to perform delta updates. (Closed)
Patch Set: fixes for review Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "update_engine/graph_utils.h" 5 #include "update_engine/graph_utils.h"
6 #include "base/basictypes.h" 6 #include "base/basictypes.h"
7 7
8 using std::vector; 8 using std::vector;
9 9
10 namespace chromeos_update_engine { 10 namespace chromeos_update_engine {
11 11
12 namespace graph_utils { 12 namespace graph_utils {
13 13
14 uint64 EdgeWeight(const Graph& graph, const Edge& edge) { 14 uint64_t EdgeWeight(const Graph& graph, const Edge& edge) {
15 uint64 weight = 0; 15 uint64_t weight = 0;
16 const vector<Extent>& extents = 16 const vector<Extent>& extents =
17 graph[edge.first].out_edges.find(edge.second)->second.extents; 17 graph[edge.first].out_edges.find(edge.second)->second.extents;
18 for (vector<Extent>::const_iterator it = extents.begin(); 18 for (vector<Extent>::const_iterator it = extents.begin();
19 it != extents.end(); ++it) { 19 it != extents.end(); ++it) {
20 if (it->start_block() != kSparseHole) 20 if (it->start_block() != kSparseHole)
21 weight += it->num_blocks(); 21 weight += it->num_blocks();
22 } 22 }
23 return weight; 23 return weight;
24 } 24 }
25 25
26 void AppendBlockToExtents(vector<Extent>* extents, uint64 block) { 26 void AppendBlockToExtents(vector<Extent>* extents, uint64_t block) {
27 if (!extents->empty()) { 27 if (!extents->empty()) {
28 Extent& extent = extents->back(); 28 Extent& extent = extents->back();
29 if (block == kSparseHole) { 29 if (block == kSparseHole) {
30 if (extent.start_block() == kSparseHole) { 30 if (extent.start_block() == kSparseHole) {
31 // Extend sparse hole extent 31 // Extend sparse hole extent
32 extent.set_num_blocks(extent.num_blocks() + 1); 32 extent.set_num_blocks(extent.num_blocks() + 1);
33 return; 33 return;
34 } else { 34 } else {
35 // Create new extent below outer 'if' 35 // Create new extent below outer 'if'
36 } 36 }
37 } else if (extent.start_block() + extent.num_blocks() == block) { 37 } else if (extent.start_block() + extent.num_blocks() == block) {
38 extent.set_num_blocks(extent.num_blocks() + 1); 38 extent.set_num_blocks(extent.num_blocks() + 1);
39 return; 39 return;
40 } 40 }
41 } 41 }
42 Extent new_extent; 42 Extent new_extent;
43 new_extent.set_start_block(block); 43 new_extent.set_start_block(block);
44 new_extent.set_num_blocks(1); 44 new_extent.set_num_blocks(1);
45 extents->push_back(new_extent); 45 extents->push_back(new_extent);
46 } 46 }
47 47
48 } // namespace graph_utils 48 } // namespace graph_utils
49 49
50 } // namespace chromeos_update_engine 50 } // namespace chromeos_update_engine
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698