| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_resetter/jtl_interpreter.h" | 5 #include "chrome/browser/profile_resetter/jtl_interpreter.h" |
| 6 | 6 |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 | 8 |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 DISALLOW_COPY_AND_ASSIGN(CompareStoredValue); | 239 DISALLOW_COPY_AND_ASSIGN(CompareStoredValue); |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 template<bool ExpectedTypeIsBooleanNotHashable> | 242 template<bool ExpectedTypeIsBooleanNotHashable> |
| 243 class StoreNodeValue : public Operation { | 243 class StoreNodeValue : public Operation { |
| 244 public: | 244 public: |
| 245 explicit StoreNodeValue(const std::string& hashed_name) | 245 explicit StoreNodeValue(const std::string& hashed_name) |
| 246 : hashed_name_(hashed_name) { | 246 : hashed_name_(hashed_name) { |
| 247 DCHECK(base::IsStringUTF8(hashed_name)); | 247 DCHECK(base::IsStringUTF8(hashed_name)); |
| 248 } | 248 } |
| 249 virtual ~StoreNodeValue() {} | 249 ~StoreNodeValue() override {} |
| 250 virtual bool Execute(ExecutionContext* context) override { | 250 bool Execute(ExecutionContext* context) override { |
| 251 scoped_ptr<base::Value> value; | 251 scoped_ptr<base::Value> value; |
| 252 if (ExpectedTypeIsBooleanNotHashable) { | 252 if (ExpectedTypeIsBooleanNotHashable) { |
| 253 if (!context->current_node()->IsType(base::Value::TYPE_BOOLEAN)) | 253 if (!context->current_node()->IsType(base::Value::TYPE_BOOLEAN)) |
| 254 return true; | 254 return true; |
| 255 value.reset(context->current_node()->DeepCopy()); | 255 value.reset(context->current_node()->DeepCopy()); |
| 256 } else { | 256 } else { |
| 257 std::string hash; | 257 std::string hash; |
| 258 if (!context->GetValueHash(*context->current_node(), &hash)) | 258 if (!context->GetValueHash(*context->current_node(), &hash)) |
| 259 return true; | 259 return true; |
| 260 value.reset(new base::StringValue(hash)); | 260 value.reset(new base::StringValue(hash)); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 private: | 375 private: |
| 376 std::string hashed_value_; | 376 std::string hashed_value_; |
| 377 DISALLOW_COPY_AND_ASSIGN(CompareNodeHashNot); | 377 DISALLOW_COPY_AND_ASSIGN(CompareNodeHashNot); |
| 378 }; | 378 }; |
| 379 | 379 |
| 380 template<bool ExpectedTypeIsBooleanNotHashable> | 380 template<bool ExpectedTypeIsBooleanNotHashable> |
| 381 class CompareNodeToStored : public Operation { | 381 class CompareNodeToStored : public Operation { |
| 382 public: | 382 public: |
| 383 explicit CompareNodeToStored(const std::string& hashed_name) | 383 explicit CompareNodeToStored(const std::string& hashed_name) |
| 384 : hashed_name_(hashed_name) {} | 384 : hashed_name_(hashed_name) {} |
| 385 virtual ~CompareNodeToStored() {} | 385 ~CompareNodeToStored() override {} |
| 386 virtual bool Execute(ExecutionContext* context) override { | 386 bool Execute(ExecutionContext* context) override { |
| 387 const base::Value* stored_value = NULL; | 387 const base::Value* stored_value = NULL; |
| 388 if (!context->working_memory()->Get(hashed_name_, &stored_value)) | 388 if (!context->working_memory()->Get(hashed_name_, &stored_value)) |
| 389 return true; | 389 return true; |
| 390 if (ExpectedTypeIsBooleanNotHashable) { | 390 if (ExpectedTypeIsBooleanNotHashable) { |
| 391 if (!context->current_node()->IsType(base::Value::TYPE_BOOLEAN) || | 391 if (!context->current_node()->IsType(base::Value::TYPE_BOOLEAN) || |
| 392 !context->current_node()->Equals(stored_value)) | 392 !context->current_node()->Equals(stored_value)) |
| 393 return true; | 393 return true; |
| 394 } else { | 394 } else { |
| 395 std::string actual_hash; | 395 std::string actual_hash; |
| 396 std::string stored_hash; | 396 std::string stored_hash; |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 return working_memory_->GetString(hashed_key, output); | 737 return working_memory_->GetString(hashed_key, output); |
| 738 } | 738 } |
| 739 | 739 |
| 740 int JtlInterpreter::CalculateProgramChecksum() const { | 740 int JtlInterpreter::CalculateProgramChecksum() const { |
| 741 uint8 digest[3] = {}; | 741 uint8 digest[3] = {}; |
| 742 crypto::SHA256HashString(program_, digest, arraysize(digest)); | 742 crypto::SHA256HashString(program_, digest, arraysize(digest)); |
| 743 return static_cast<uint32>(digest[0]) << 16 | | 743 return static_cast<uint32>(digest[0]) << 16 | |
| 744 static_cast<uint32>(digest[1]) << 8 | | 744 static_cast<uint32>(digest[1]) << 8 | |
| 745 static_cast<uint32>(digest[2]); | 745 static_cast<uint32>(digest[2]); |
| 746 } | 746 } |
| OLD | NEW |