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

Side by Side Diff: chrome/common/web_resource/web_resource_unpacker.h

Issue 3522004: FBTF: Move ctors/dtors into implementation files. Adds ctors/dtors to non-POD structs. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 2 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This class is called by the WebResourceService in a sandboxed process 5 // This class is called by the WebResourceService in a sandboxed process
6 // to unpack data retrieved from a web resource feed. Right now, it 6 // to unpack data retrieved from a web resource feed. Right now, it
7 // takes a string of data in JSON format, parses it, and hands it back 7 // takes a string of data in JSON format, parses it, and hands it back
8 // to the WebResourceService as a list of items. In the future 8 // to the WebResourceService as a list of items. In the future
9 // it will be set up to unpack and verify image data in addition to 9 // it will be set up to unpack and verify image data in addition to
10 // just parsing a JSON feed. 10 // just parsing a JSON feed.
11 11
12 #ifndef CHROME_COMMON_WEB_RESOURCE_WEB_RESOURCE_UNPACKER_H_ 12 #ifndef CHROME_COMMON_WEB_RESOURCE_WEB_RESOURCE_UNPACKER_H_
13 #define CHROME_COMMON_WEB_RESOURCE_WEB_RESOURCE_UNPACKER_H_ 13 #define CHROME_COMMON_WEB_RESOURCE_WEB_RESOURCE_UNPACKER_H_
14 #pragma once 14 #pragma once
15 15
16 #include <string> 16 #include <string>
17 17
18 #include "base/basictypes.h" 18 #include "base/basictypes.h"
19 #include "base/scoped_ptr.h" 19 #include "base/scoped_ptr.h"
20 20
21 class DictionaryValue; 21 class DictionaryValue;
22 22
23 class WebResourceUnpacker { 23 class WebResourceUnpacker {
24 public: 24 public:
25 static const char* kInvalidDataTypeError; 25 static const char* kInvalidDataTypeError;
26 static const char* kUnexpectedJSONFormatError; 26 static const char* kUnexpectedJSONFormatError;
27 27
28 explicit WebResourceUnpacker(const std::string &resource_data) 28 explicit WebResourceUnpacker(const std::string &resource_data);
29 : resource_data_(resource_data) {} 29 ~WebResourceUnpacker();
30 30
31 // This does the actual parsing. In case of an error, error_message_ 31 // This does the actual parsing. In case of an error, error_message_
32 // is set to an appropriate value. 32 // is set to an appropriate value.
33 bool Run(); 33 bool Run();
34 34
35 // Returns the last error message set by Run(). 35 // Returns the last error message set by Run().
36 const std::string& error_message() { return error_message_; } 36 const std::string& error_message() { return error_message_; }
37 37
38 // Gets data which has been parsed by Run(). 38 // Gets data which has been parsed by Run().
39 DictionaryValue* parsed_json() { 39 DictionaryValue* parsed_json() {
40 return parsed_json_.get(); 40 return parsed_json_.get();
41 } 41 }
42 42
43 private: 43 private:
44 // Holds the string which is to be parsed. 44 // Holds the string which is to be parsed.
45 std::string resource_data_; 45 std::string resource_data_;
46 46
47 // Holds the result of JSON parsing of resource_data_. 47 // Holds the result of JSON parsing of resource_data_.
48 scoped_ptr<DictionaryValue> parsed_json_; 48 scoped_ptr<DictionaryValue> parsed_json_;
49 49
50 // Holds the last error message produced by Run(). 50 // Holds the last error message produced by Run().
51 std::string error_message_; 51 std::string error_message_;
52 52
53 DISALLOW_COPY_AND_ASSIGN(WebResourceUnpacker); 53 DISALLOW_COPY_AND_ASSIGN(WebResourceUnpacker);
54 }; 54 };
55 55
56 #endif // CHROME_COMMON_WEB_RESOURCE_WEB_RESOURCE_UNPACKER_H_ 56 #endif // CHROME_COMMON_WEB_RESOURCE_WEB_RESOURCE_UNPACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698