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

Side by Side Diff: chrome/test/chromedriver/status.cc

Issue 11415205: [chromedriver] Implement connecting to devtools and loading a page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/status.h" 5 #include "chrome/test/chromedriver/status.h"
6 6
7 #include <vector>
8
9 #include "base/string_split.h"
chrisgao (Use stgao instead) 2012/12/01 08:37:19 It seems unused.
kkania 2013/02/28 21:51:58 Done.
10
7 namespace { 11 namespace {
8 12
9 // Returns the string equivalent of the given |ErrorCode|. 13 // Returns the string equivalent of the given |ErrorCode|.
10 const char* DefaultMessageForStatusCode(StatusCode code) { 14 const char* DefaultMessageForStatusCode(StatusCode code) {
11 switch (code) { 15 switch (code) {
12 case kOk: 16 case kOk:
13 return "ok"; 17 return "ok";
14 case kUnknownCommand: 18 case kUnknownCommand:
15 return "unknown command"; 19 return "unknown command";
16 case kUnknownError: 20 case kUnknownError:
17 return "unknown error"; 21 return "unknown error";
18 case kSessionNotCreatedException: 22 case kSessionNotCreatedException:
19 return "session not created exception"; 23 return "session not created exception";
20 case kNoSuchSession: 24 case kNoSuchSession:
21 return "no such session"; 25 return "no such session";
26 case kChromeNotReachable:
27 return "chrome not reachable";
22 default: 28 default:
23 return "<unknown>"; 29 return "<unknown>";
24 } 30 }
25 } 31 }
26 32
27 } // namespace 33 } // namespace
28 34
29 Status::Status(StatusCode code) 35 Status::Status(StatusCode code)
30 : code_(code), msg_(DefaultMessageForStatusCode(code)) {} 36 : code_(code), msg_(DefaultMessageForStatusCode(code)) {}
31 37
32 Status::Status(StatusCode code, const std::string& details) 38 Status::Status(StatusCode code, const std::string& details)
33 : code_(code), 39 : code_(code),
34 msg_(DefaultMessageForStatusCode(code) + std::string(": ") + details) { 40 msg_(DefaultMessageForStatusCode(code) + std::string(": ") + details) {
35 } 41 }
36 42
43 Status::Status(StatusCode code, const Status& cause)
44 : code_(code),
45 msg_(DefaultMessageForStatusCode(code) + std::string("\nfrom ") +
46 cause.message()) {}
47
48 Status::Status(StatusCode code,
49 const std::string& details,
50 const Status& cause)
51 : code_(code),
52 msg_(DefaultMessageForStatusCode(code) + std::string(": ") + details +
53 "\nfrom " + cause.message()) {
54 }
55
56 Status::~Status() {}
57
37 bool Status::IsOk() const { 58 bool Status::IsOk() const {
38 return code_ == kOk; 59 return code_ == kOk;
39 } 60 }
40 61
41 bool Status::IsError() const { 62 bool Status::IsError() const {
42 return code_ != kOk; 63 return code_ != kOk;
43 } 64 }
44 65
45 StatusCode Status::code() const { 66 StatusCode Status::code() const {
46 return code_; 67 return code_;
47 } 68 }
48 69
49 const std::string& Status::message() const { 70 const std::string& Status::message() const {
50 return msg_; 71 return msg_;
51 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698