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

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

Issue 316016: Move the json-related files into a separate json directory. This hopefully al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/sandbox_mac.mm ('k') | chrome/renderer/dom_ui_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 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 #include "chrome/common/web_resource/web_resource_unpacker.h" 5 #include "chrome/common/web_resource/web_resource_unpacker.h"
6 6
7 #include "base/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 9
10 const char* WebResourceUnpacker::kInvalidDataTypeError = 10 const char* WebResourceUnpacker::kInvalidDataTypeError =
11 "Data from web resource server is missing or not valid JSON."; 11 "Data from web resource server is missing or not valid JSON.";
12 12
13 const char* WebResourceUnpacker::kUnexpectedJSONFormatError = 13 const char* WebResourceUnpacker::kUnexpectedJSONFormatError =
14 "Data from web resource server does not have expected format."; 14 "Data from web resource server does not have expected format.";
15 15
16 // TODO(mrc): Right now, this reads JSON data from the experimental popgadget 16 // TODO(mrc): Right now, this reads JSON data from the experimental popgadget
17 // server. Change so the format is based on a template, once we have 17 // server. Change so the format is based on a template, once we have
18 // decided on final server format. 18 // decided on final server format.
19 bool WebResourceUnpacker::Run() { 19 bool WebResourceUnpacker::Run() {
20 scoped_ptr<Value> value; 20 scoped_ptr<Value> value;
21 if (!resource_data_.empty()) { 21 if (!resource_data_.empty()) {
22 value.reset(JSONReader::Read(resource_data_, false)); 22 value.reset(base::JSONReader::Read(resource_data_, false));
23 if (!value.get()) { 23 if (!value.get()) {
24 // Page information not properly read, or corrupted. 24 // Page information not properly read, or corrupted.
25 error_message_ = kInvalidDataTypeError; 25 error_message_ = kInvalidDataTypeError;
26 return false; 26 return false;
27 } 27 }
28 if (!value->IsType(Value::TYPE_DICTIONARY)) { 28 if (!value->IsType(Value::TYPE_DICTIONARY)) {
29 error_message_ = kUnexpectedJSONFormatError; 29 error_message_ = kUnexpectedJSONFormatError;
30 return false; 30 return false;
31 } 31 }
32 parsed_json_.reset(static_cast<DictionaryValue*>(value.release())); 32 parsed_json_.reset(static_cast<DictionaryValue*>(value.release()));
33 return true; 33 return true;
34 } 34 }
35 error_message_ = kInvalidDataTypeError; 35 error_message_ = kInvalidDataTypeError;
36 return false; 36 return false;
37 } 37 }
38 38
OLDNEW
« no previous file with comments | « chrome/common/sandbox_mac.mm ('k') | chrome/renderer/dom_ui_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698