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

Unified Diff: chrome/common/extensions/value_builder.h

Issue 48643003: Moved extension and value builder code to extensions component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again Created 7 years, 1 month 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
« no previous file with comments | « chrome/common/extensions/manifest_handler_unittest.cc ('k') | chrome/common/extensions/value_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/value_builder.h
diff --git a/chrome/common/extensions/value_builder.h b/chrome/common/extensions/value_builder.h
deleted file mode 100644
index db272c5cef8a32d93dd3e51ee16b9821913c958a..0000000000000000000000000000000000000000
--- a/chrome/common/extensions/value_builder.h
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2012 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.
-
-// This file provides a builders for DictionaryValue and ListValue. These
-// aren't specific to extensions and could move up to base/ if there's interest
-// from other sub-projects.
-//
-// The general pattern is to write:
-//
-// scoped_ptr<BuiltType> result(FooBuilder()
-// .Set(args)
-// .Set(args)
-// .Build());
-//
-// For methods that take other built types, you can pass the builder directly
-// to the setter without calling Build():
-//
-// DictionaryBuilder().Set("key", ListBuilder()
-// .Append("foo").Append("bar") /* No .Build() */);
-//
-// Because of limitations in C++03, and to avoid extra copies, you can't pass a
-// just-constructed Builder into another Builder's method directly. Use the
-// Pass() method.
-//
-// The Build() method invalidates its builder, and returns ownership of the
-// built value.
-//
-// These objects are intended to be used as temporaries rather than stored
-// anywhere, so the use of non-const reference parameters is likely to cause
-// less confusion than usual.
-
-#ifndef CHROME_COMMON_EXTENSIONS_VALUE_BUILDER_H_
-#define CHROME_COMMON_EXTENSIONS_VALUE_BUILDER_H_
-
-#include <string>
-
-#include "base/memory/scoped_ptr.h"
-#include "base/strings/string16.h"
-#include "base/values.h"
-
-namespace extensions {
-
-class ListBuilder;
-
-class DictionaryBuilder {
- public:
- DictionaryBuilder();
- explicit DictionaryBuilder(const base::DictionaryValue& init);
- ~DictionaryBuilder();
-
- // Workaround to allow you to pass rvalue ExtensionBuilders by reference to
- // other functions.
- DictionaryBuilder& Pass() { return *this; }
-
- // Can only be called once, after which it's invalid to use the builder.
- scoped_ptr<base::DictionaryValue> Build() { return dict_.Pass(); }
-
- DictionaryBuilder& Set(const std::string& path, int in_value);
- DictionaryBuilder& Set(const std::string& path, double in_value);
- DictionaryBuilder& Set(const std::string& path, const std::string& in_value);
- DictionaryBuilder& Set(const std::string& path, const string16& in_value);
- DictionaryBuilder& Set(const std::string& path, DictionaryBuilder& in_value);
- DictionaryBuilder& Set(const std::string& path, ListBuilder& in_value);
-
- // Named differently because overload resolution is too eager to
- // convert implicitly to bool.
- DictionaryBuilder& SetBoolean(const std::string& path, bool in_value);
-
- private:
- scoped_ptr<base::DictionaryValue> dict_;
-};
-
-class ListBuilder {
- public:
- ListBuilder();
- explicit ListBuilder(const base::ListValue& init);
- ~ListBuilder();
-
- // Workaround to allow you to pass rvalue ExtensionBuilders by reference to
- // other functions.
- ListBuilder& Pass() { return *this; }
-
- // Can only be called once, after which it's invalid to use the builder.
- scoped_ptr<base::ListValue> Build() { return list_.Pass(); }
-
- ListBuilder& Append(int in_value);
- ListBuilder& Append(double in_value);
- ListBuilder& Append(const std::string& in_value);
- ListBuilder& Append(const string16& in_value);
- ListBuilder& Append(DictionaryBuilder& in_value);
- ListBuilder& Append(ListBuilder& in_value);
-
- // Named differently because overload resolution is too eager to
- // convert implicitly to bool.
- ListBuilder& AppendBoolean(bool in_value);
-
- private:
- scoped_ptr<base::ListValue> list_;
-};
-
-} // namespace extensions
-
-#endif // CHROME_COMMON_EXTENSIONS_VALUE_BUILDER_H_
« no previous file with comments | « chrome/common/extensions/manifest_handler_unittest.cc ('k') | chrome/common/extensions/value_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698