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

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: address comments 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
« no previous file with comments | « chrome/test/chromedriver/status.h ('k') | chrome/test/chromedriver/status_unittest.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) 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 namespace { 7 namespace {
8 8
9 // Returns the string equivalent of the given |ErrorCode|. 9 // Returns the string equivalent of the given |ErrorCode|.
10 const char* DefaultMessageForStatusCode(StatusCode code) { 10 const char* DefaultMessageForStatusCode(StatusCode code) {
11 switch (code) { 11 switch (code) {
12 case kOk: 12 case kOk:
13 return "ok"; 13 return "ok";
14 case kUnknownCommand: 14 case kUnknownCommand:
15 return "unknown command"; 15 return "unknown command";
16 case kUnknownError: 16 case kUnknownError:
17 return "unknown error"; 17 return "unknown error";
18 case kSessionNotCreatedException: 18 case kSessionNotCreatedException:
19 return "session not created exception"; 19 return "session not created exception";
20 case kNoSuchSession: 20 case kNoSuchSession:
21 return "no such session"; 21 return "no such session";
22 case kChromeNotReachable:
23 return "chrome not reachable";
22 default: 24 default:
23 return "<unknown>"; 25 return "<unknown>";
24 } 26 }
25 } 27 }
26 28
27 } // namespace 29 } // namespace
28 30
29 Status::Status(StatusCode code) 31 Status::Status(StatusCode code)
30 : code_(code), msg_(DefaultMessageForStatusCode(code)) {} 32 : code_(code), msg_(DefaultMessageForStatusCode(code)) {}
31 33
32 Status::Status(StatusCode code, const std::string& details) 34 Status::Status(StatusCode code, const std::string& details)
33 : code_(code), 35 : code_(code),
34 msg_(DefaultMessageForStatusCode(code) + std::string(": ") + details) { 36 msg_(DefaultMessageForStatusCode(code) + std::string(": ") + details) {
35 } 37 }
36 38
39 Status::Status(StatusCode code, const Status& cause)
40 : code_(code),
41 msg_(DefaultMessageForStatusCode(code) + std::string("\nfrom ") +
42 cause.message()) {}
43
44 Status::Status(StatusCode code,
45 const std::string& details,
46 const Status& cause)
47 : code_(code),
48 msg_(DefaultMessageForStatusCode(code) + std::string(": ") + details +
49 "\nfrom " + cause.message()) {
50 }
51
52 Status::~Status() {}
53
37 bool Status::IsOk() const { 54 bool Status::IsOk() const {
38 return code_ == kOk; 55 return code_ == kOk;
39 } 56 }
40 57
41 bool Status::IsError() const { 58 bool Status::IsError() const {
42 return code_ != kOk; 59 return code_ != kOk;
43 } 60 }
44 61
45 StatusCode Status::code() const { 62 StatusCode Status::code() const {
46 return code_; 63 return code_;
47 } 64 }
48 65
49 const std::string& Status::message() const { 66 const std::string& Status::message() const {
50 return msg_; 67 return msg_;
51 } 68 }
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/status.h ('k') | chrome/test/chromedriver/status_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698