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

Unified Diff: chrome/browser/profile_resetter/jtl_interpreter.h

Issue 533183002: Revert "Eliminate all code related to the AutomaticProfileResetter." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profile_resetter/jtl_interpreter.h
diff --git a/chrome/browser/profile_resetter/jtl_interpreter.h b/chrome/browser/profile_resetter/jtl_interpreter.h
new file mode 100644
index 0000000000000000000000000000000000000000..cafb7fdb01abbf91c32d54bcb9474ca75d295a0f
--- /dev/null
+++ b/chrome/browser/profile_resetter/jtl_interpreter.h
@@ -0,0 +1,61 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PROFILE_RESETTER_JTL_INTERPRETER_H_
+#define CHROME_BROWSER_PROFILE_RESETTER_JTL_INTERPRETER_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/values.h"
+
+// Executes a JTL program on a given dictionary.
+//
+// JTL (Json Traversal Language) programs are defined in jtl_foundation.h
+class JtlInterpreter {
+ public:
+ enum Result {
+ OK,
+ PARSE_ERROR,
+ RUNTIME_ERROR,
+ RESULT_MAX,
+ };
+
+ // |hasher_seed| is a value used in jtl_foundation::Hasher. All node names,
+ // strings, integers and doubles are hashed before being compared to hash
+ // values listed in |program|.
+ // |program| is a byte array containing a JTL program.
+ // |input| is a dictionary on which the program is evaluated.
+ JtlInterpreter(const std::string& hasher_seed,
+ const std::string& program,
+ const base::DictionaryValue* input);
+ ~JtlInterpreter();
+
+ void Execute();
+
+ Result result() const { return result_; }
+ const base::DictionaryValue* working_memory() const {
+ return working_memory_.get();
+ }
+ bool GetOutputBoolean(const std::string& unhashed_key, bool* output) const;
+ bool GetOutputString(const std::string& unhashed_key,
+ std::string* output) const;
+
+ // Generates a checksum of the loaded program, defined as the first 3 bytes of
+ // the program's SHA-256 hash interpreted as a big-endian integer.
+ int CalculateProgramChecksum() const;
+
+ private:
+ // Input.
+ std::string hasher_seed_;
+ std::string program_;
+ const base::DictionaryValue* input_;
+ // Output.
+ scoped_ptr<base::DictionaryValue> working_memory_;
+ Result result_;
+
+ DISALLOW_COPY_AND_ASSIGN(JtlInterpreter);
+};
+
+#endif // CHROME_BROWSER_PROFILE_RESETTER_JTL_INTERPRETER_H_
« no previous file with comments | « chrome/browser/profile_resetter/jtl_instructions.h ('k') | chrome/browser/profile_resetter/jtl_interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698