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

Side by Side Diff: chrome/test/chromedriver/server/http_handler.cc

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 years, 8 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/test/chromedriver/server/http_handler.h" 5 #include "chrome/test/chromedriver/server/http_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
16 #include "base/logging.h" // For CHECK macros. 16 #include "base/logging.h" // For CHECK macros.
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h"
18 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
19 #include "base/strings/string_split.h" 20 #include "base/strings/string_split.h"
20 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
21 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
22 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
23 #include "base/sys_info.h" 24 #include "base/sys_info.h"
24 #include "base/threading/thread_task_runner_handle.h" 25 #include "base/threading/thread_task_runner_handle.h"
25 #include "base/values.h" 26 #include "base/values.h"
26 #include "build/build_config.h" 27 #include "build/build_config.h"
27 #include "chrome/test/chromedriver/alert_commands.h" 28 #include "chrome/test/chromedriver/alert_commands.h"
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 "Driver info: chromedriver=%s,platform=%s %s %s", 750 "Driver info: chromedriver=%s,platform=%s %s %s",
750 kChromeDriverVersion, 751 kChromeDriverVersion,
751 base::SysInfo::OperatingSystemName().c_str(), 752 base::SysInfo::OperatingSystemName().c_str(),
752 base::SysInfo::OperatingSystemVersion().c_str(), 753 base::SysInfo::OperatingSystemVersion().c_str(),
753 base::SysInfo::OperatingSystemArchitecture().c_str())); 754 base::SysInfo::OperatingSystemArchitecture().c_str()));
754 std::unique_ptr<base::DictionaryValue> error(new base::DictionaryValue()); 755 std::unique_ptr<base::DictionaryValue> error(new base::DictionaryValue());
755 error->SetString("message", full_status.message()); 756 error->SetString("message", full_status.message());
756 value.reset(error.release()); 757 value.reset(error.release());
757 } 758 }
758 if (!value) 759 if (!value)
759 value = base::Value::CreateNullValue(); 760 value = base::MakeUnique<base::Value>();
760 761
761 base::DictionaryValue body_params; 762 base::DictionaryValue body_params;
762 body_params.SetInteger("status", status.code()); 763 body_params.SetInteger("status", status.code());
763 body_params.Set("value", value.release()); 764 body_params.Set("value", value.release());
764 body_params.SetString("sessionId", session_id); 765 body_params.SetString("sessionId", session_id);
765 std::string body; 766 std::string body;
766 base::JSONWriter::WriteWithOptions( 767 base::JSONWriter::WriteWithOptions(
767 body_params, base::JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION, 768 body_params, base::JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION,
768 &body); 769 &body);
769 std::unique_ptr<net::HttpServerResponseInfo> response( 770 std::unique_ptr<net::HttpServerResponseInfo> response(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 case kChromeNotReachable: 813 case kChromeNotReachable:
813 case kDisconnected: 814 case kDisconnected:
814 case kForbidden: 815 case kForbidden:
815 case kTabCrashed: 816 case kTabCrashed:
816 response.reset( 817 response.reset(
817 new net::HttpServerResponseInfo(net::HTTP_INTERNAL_SERVER_ERROR)); 818 new net::HttpServerResponseInfo(net::HTTP_INTERNAL_SERVER_ERROR));
818 break; 819 break;
819 } 820 }
820 821
821 if (!value) 822 if (!value)
822 value = base::Value::CreateNullValue(); 823 value = base::MakeUnique<base::Value>();
823 824
824 base::DictionaryValue body_params; 825 base::DictionaryValue body_params;
825 if (status.IsError()){ 826 if (status.IsError()){
826 // Separates status default message from additional details. 827 // Separates status default message from additional details.
827 std::vector<std::string> status_details = base::SplitString( 828 std::vector<std::string> status_details = base::SplitString(
828 status.message(), ":\n", base::TRIM_WHITESPACE, 829 status.message(), ":\n", base::TRIM_WHITESPACE,
829 base::SPLIT_WANT_NONEMPTY); 830 base::SPLIT_WANT_NONEMPTY);
830 std::string message; 831 std::string message;
831 for (size_t i=1; i<status_details.size();++i) 832 for (size_t i=1; i<status_details.size();++i)
832 message += status_details[i]; 833 message += status_details[i];
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 params.SetString(name, decoded); 904 params.SetString(name, decoded);
904 } else if (command_path_parts[i] != path_parts[i]) { 905 } else if (command_path_parts[i] != path_parts[i]) {
905 return false; 906 return false;
906 } 907 }
907 } 908 }
908 out_params->MergeDictionary(&params); 909 out_params->MergeDictionary(&params);
909 return true; 910 return true;
910 } 911 }
911 912
912 } // namespace internal 913 } // namespace internal
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/commands_unittest.cc ('k') | components/arc/bluetooth/bluetooth_type_converters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698