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

Side by Side Diff: ios/chrome/browser/web_resource/web_resource_util.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ios/chrome/browser/web_resource/web_resource_util.h" 5 #include "ios/chrome/browser/web_resource/web_resource_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/task_runner.h" 10 #include "base/task_runner.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return; 42 return;
43 } 43 }
44 44
45 std::unique_ptr<base::Value> value(base::JSONReader::Read(data)); 45 std::unique_ptr<base::Value> value(base::JSONReader::Read(data));
46 if (!value.get()) { 46 if (!value.get()) {
47 // Page information not properly read, or corrupted. 47 // Page information not properly read, or corrupted.
48 PostErrorTask(task_runner, error_callback, kInvalidDataTypeError); 48 PostErrorTask(task_runner, error_callback, kInvalidDataTypeError);
49 return; 49 return;
50 } 50 }
51 51
52 if (!value->IsType(base::Value::TYPE_DICTIONARY)) { 52 if (!value->IsType(base::Value::Type::DICTIONARY)) {
53 PostErrorTask(task_runner, error_callback, kUnexpectedJSONFormatError); 53 PostErrorTask(task_runner, error_callback, kUnexpectedJSONFormatError);
54 return; 54 return;
55 } 55 }
56 56
57 task_runner->PostTask(FROM_HERE, 57 task_runner->PostTask(FROM_HERE,
58 base::Bind(success_callback, base::Passed(&value))); 58 base::Bind(success_callback, base::Passed(&value)));
59 } 59 }
60 60
61 // Starts the parsing of |data| as a JSON string asynchronously on a background 61 // Starts the parsing of |data| as a JSON string asynchronously on a background
62 // thread. Can be called from the UI thread. 62 // thread. Can be called from the UI thread.
63 void StartParseJSONAsync( 63 void StartParseJSONAsync(
64 const std::string& data, 64 const std::string& data,
65 const WebResourceService::SuccessCallback& success_callback, 65 const WebResourceService::SuccessCallback& success_callback,
66 const WebResourceService::ErrorCallback& error_callback) { 66 const WebResourceService::ErrorCallback& error_callback) {
67 web::WebThread::PostBlockingPoolTask( 67 web::WebThread::PostBlockingPoolTask(
68 FROM_HERE, 68 FROM_HERE,
69 base::Bind(&ParseJSONOnBackgroundThread, 69 base::Bind(&ParseJSONOnBackgroundThread,
70 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), data, 70 base::RetainedRef(base::ThreadTaskRunnerHandle::Get()), data,
71 success_callback, error_callback)); 71 success_callback, error_callback));
72 } 72 }
73 73
74 } // namespace 74 } // namespace
75 75
76 WebResourceService::ParseJSONCallback GetIOSChromeParseJSONCallback() { 76 WebResourceService::ParseJSONCallback GetIOSChromeParseJSONCallback() {
77 return base::Bind(&StartParseJSONAsync); 77 return base::Bind(&StartParseJSONAsync);
78 } 78 }
79 79
80 } // namespace web_resource 80 } // namespace web_resource
OLDNEW
« no previous file with comments | « ios/chrome/browser/passwords/password_controller.mm ('k') | ios/web/public/web_state/web_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698