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

Side by Side Diff: chrome/browser/local_discovery/privetv3_session.h

Issue 314303009: Comments and style nits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fri 06/06/2014 10:50:14.11 Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_ 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_ 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/values.h" 12
13 namespace base {
14 class DictionaryValue;
15 }
13 16
14 namespace local_discovery { 17 namespace local_discovery {
15 18
16 class PrivetHTTPClient; 19 class PrivetHTTPClient;
17 20
21 // Manages secure communication between browser and local Privet device.
18 class PrivetV3Session { 22 class PrivetV3Session {
19 public: 23 public:
20 typedef base::Callback< 24 typedef base::Callback<
21 void(bool success, const base::DictionaryValue& response)> 25 void(bool success, const base::DictionaryValue& response)>
22 RequestCallback; 26 RequestCallback;
23 27
28 // Delegate to be implemented by client code.
24 class Delegate { 29 class Delegate {
25 public: 30 public:
26 typedef base::Callback<void(bool confirm)> ConfirmationCallback; 31 typedef base::Callback<void(bool confirm)> ConfirmationCallback;
27 32
28 virtual ~Delegate() {} 33 virtual ~Delegate() {}
29 34
35 // Called when client code should prompt user to check |confirmation_code|.
30 virtual void OnSetupConfirmationNeeded( 36 virtual void OnSetupConfirmationNeeded(
31 const std::string& confirmation_code, 37 const std::string& confirmation_code,
32 const ConfirmationCallback& callback) = 0; 38 const ConfirmationCallback& callback) = 0;
33 39
40 // Called when session successfully establish and client code my call
41 // |CreateRequest| method.
34 virtual void OnSessionEstablished() = 0; 42 virtual void OnSessionEstablished() = 0;
35 43
44 // Called when session setup fails.
36 virtual void OnCannotEstablishSession() = 0; 45 virtual void OnCannotEstablishSession() = 0;
37 }; 46 };
38 47
48 // Represents request in progress using secure session.
39 class Request { 49 class Request {
40 public: 50 public:
41 virtual ~Request() {} 51 ~Request() {}
42 52 void Start() {}
gene 2014/06/06 18:17:16 why did you remove virtual and pure virtual?
Vitaly Buka (NO REVIEWS) 2014/06/06 18:52:56 Done.
43 virtual void Start() = 0;
44 }; 53 };
45 54
46 virtual ~PrivetV3Session() {} 55 PrivetV3Session(scoped_ptr<PrivetHTTPClient> client, Delegate* delegate);
47 56
48 static scoped_ptr<PrivetV3Session> Create(PrivetHTTPClient* client); 57 ~PrivetV3Session();
49 58
50 // Establish a session, will call |OnSetupConfirmationNeeded| and then 59 // Establishes a session, will call |OnSetupConfirmationNeeded| and then
51 // |OnSessionEstablished|. 60 // |OnSessionEstablished|.
52 virtual void Start() = 0; 61 void Start();
53 62
54 // Create a single /privet/v2/session/call request. 63 // Create a single /privet/v3/session/call request.
55 virtual scoped_ptr<Request> CreateRequest( 64 // Must be called only after receiving |OnSessionEstablished|.
56 const char* api_name, 65 scoped_ptr<Request> CreateRequest(const std::string& api_name,
57 const base::DictionaryValue& request, 66 const base::DictionaryValue& request,
58 const RequestCallback& callback); 67 const RequestCallback& callback);
68
69 private:
70 DISALLOW_COPY_AND_ASSIGN(PrivetV3Session);
59 }; 71 };
60 72
61 } // namespace local_discovery 73 } // namespace local_discovery
62 74
63 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_ 75 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privet_http_asynchronous_factory.h ('k') | chrome/browser/local_discovery/privetv3_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698