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

Side by Side Diff: components/safe_json_parser/safe_json_parser.h

Issue 1140053003: Refactoring: Moving the SafeJsonParser to its own component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Localized string, build fixes Created 5 years, 6 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 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 #ifndef CHROME_BROWSER_SAFE_JSON_PARSER_H_ 5 #ifndef COMPONENTS_SAFE_JSON_PARSER_SAFE_JSON_PARSER_H_
6 #define CHROME_BROWSER_SAFE_JSON_PARSER_H_ 6 #define COMPONENTS_SAFE_JSON_PARSER_SAFE_JSON_PARSER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "components/safe_json_parser/safe_json_parser_export.h"
13 #include "content/public/browser/utility_process_host_client.h" 14 #include "content/public/browser/utility_process_host_client.h"
14 15
15 namespace base { 16 namespace base {
16 class ListValue; 17 class ListValue;
17 class Value; 18 class Value;
18 } 19 }
19 20
20 namespace IPC { 21 namespace IPC {
21 class Message; 22 class Message;
22 } 23 }
23 24
25 namespace safe_json_parser {
26
24 // SafeJsonParser parses a given JSON safely via a utility process. The object 27 // SafeJsonParser parses a given JSON safely via a utility process. The object
25 // is ref-counted and kept alive after Start() is called until one of the two 28 // is ref-counted and kept alive after Start() is called until one of the two
26 // callbacks is called. 29 // callbacks is called.
27 class SafeJsonParser : public content::UtilityProcessHostClient { 30 class SafeJsonParser
Robert Sesek 2015/05/26 19:39:27 Does this need the EXPORT macro?
Eran Messeri 2015/05/28 13:54:27 No - compiles fine on Windows without it (it's a s
31 : public content::UtilityProcessHostClient {
28 public: 32 public:
29 typedef base::Callback<void(scoped_ptr<base::Value>)> SuccessCallback; 33 typedef base::Callback<void(scoped_ptr<base::Value>)> SuccessCallback;
30 typedef base::Callback<void(const std::string&)> ErrorCallback; 34 typedef base::Callback<void(const std::string&)> ErrorCallback;
31 35
32 SafeJsonParser(const std::string& unsafe_json, 36 SafeJsonParser(const std::string& unsafe_json,
33 const SuccessCallback& success_callback, 37 const SuccessCallback& success_callback,
34 const ErrorCallback& error_callback); 38 const ErrorCallback& error_callback);
35 39
36 void Start(); 40 void Start();
37 41
(...skipping 14 matching lines...) Expand all
52 const std::string unsafe_json_; 56 const std::string unsafe_json_;
53 SuccessCallback success_callback_; 57 SuccessCallback success_callback_;
54 ErrorCallback error_callback_; 58 ErrorCallback error_callback_;
55 59
56 scoped_ptr<base::Value> parsed_json_; 60 scoped_ptr<base::Value> parsed_json_;
57 std::string error_; 61 std::string error_;
58 62
59 DISALLOW_COPY_AND_ASSIGN(SafeJsonParser); 63 DISALLOW_COPY_AND_ASSIGN(SafeJsonParser);
60 }; 64 };
61 65
62 #endif // CHROME_BROWSER_SAFE_JSON_PARSER_H_ 66 } // namespace safe_json_parser
67
68 #endif // COMPONENTS_SAFE_JSON_PARSER_SAFE_JSON_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698