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

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

Issue 19224002: Get rid of single process code path in json_asynchronous_unpacker.cc. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: move web_resource_unpacker Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/common/web_resource/web_resource_unpacker.h"
6
7 #include "base/json/json_reader.h"
8 #include "base/values.h"
9
10 const char* WebResourceUnpacker::kInvalidDataTypeError =
11 "Data from web resource server is missing or not valid JSON.";
12
13 const char* WebResourceUnpacker::kUnexpectedJSONFormatError =
14 "Data from web resource server does not have expected format.";
15
16 WebResourceUnpacker::WebResourceUnpacker(const std::string &resource_data)
17 : resource_data_(resource_data) {
18 }
19
20 WebResourceUnpacker::~WebResourceUnpacker() {
21 }
22
23 // TODO(mrc): Right now, this reads JSON data from the experimental popgadget
24 // server. Change so the format is based on a template, once we have
25 // decided on final server format.
26 bool WebResourceUnpacker::Run() {
27 scoped_ptr<base::Value> value;
28 if (!resource_data_.empty()) {
29 value.reset(base::JSONReader::Read(resource_data_));
30 if (!value.get()) {
31 // Page information not properly read, or corrupted.
32 error_message_ = kInvalidDataTypeError;
33 return false;
34 }
35 if (!value->IsType(base::Value::TYPE_DICTIONARY)) {
36 error_message_ = kUnexpectedJSONFormatError;
37 return false;
38 }
39 parsed_json_.reset(static_cast<base::DictionaryValue*>(value.release()));
40 return true;
41 }
42 error_message_ = kInvalidDataTypeError;
43 return false;
44 }
45
OLDNEW
« no previous file with comments | « chrome/common/web_resource/web_resource_unpacker.h ('k') | chrome/utility/chrome_content_utility_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698