Merge lp:~marcustomlinson/unity-scope-youtube/oa_start_timeout into lp:unity-scope-youtube

Proposed by Marcus Tomlinson
Status: Merged
Approved by: Pete Woods
Approved revision: 105
Merged at revision: 105
Proposed branch: lp:~marcustomlinson/unity-scope-youtube/oa_start_timeout
Merge into: lp:unity-scope-youtube
Diff against target: 94 lines (+17/-6)
5 files modified
CMakeLists.txt (+1/-1)
debian/control (+1/-1)
include/youtube/api/config.h (+1/-1)
include/youtube/scope/scope.h (+3/-0)
src/youtube/scope/scope.cpp (+11/-3)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scope-youtube/oa_start_timeout
Reviewer Review Type Date Requested Status
Pete Woods Approve
Review via email: mp+238140@code.launchpad.net

Commit message

Don't hold up the start() method for too long waiting for OA to reply (Timeout after 2s), and updated unity-scopes-api dependancy to version 0.6.7

To post a comment you must log in.
Revision history for this message
Pete Woods (pete-woods) wrote :

Looks good to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-09-16 10:39:19 +0000
3+++ CMakeLists.txt 2014-10-13 12:17:24 +0000
4@@ -27,7 +27,7 @@
5 SCOPE
6 glib-2.0
7 gio-unix-2.0
8- libunity-scopes>=0.6.6
9+ libunity-scopes>=0.6.7
10 jsoncpp
11 net-cpp>=1.1.0
12 process-cpp
13
14=== modified file 'debian/control'
15--- debian/control 2014-09-16 11:40:39 +0000
16+++ debian/control 2014-10-13 12:17:24 +0000
17@@ -15,7 +15,7 @@
18 libjsoncpp-dev,
19 libnet-cpp-dev (>= 1.1.0),
20 libprocess-cpp-dev,
21- libunity-scopes-dev (>= 0.6.6),
22+ libunity-scopes-dev (>= 0.6.7),
23 pkg-config,
24 python-tornado,
25 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
26
27=== modified file 'include/youtube/api/config.h'
28--- include/youtube/api/config.h 2014-08-11 10:35:09 +0000
29+++ include/youtube/api/config.h 2014-10-13 12:17:24 +0000
30@@ -63,7 +63,7 @@
31 */
32 std::string accept {"application/json"};
33
34- /**
35+ /*
36 * Have we got access to private APIs?
37 */
38 bool authenticated = false;
39
40=== modified file 'include/youtube/scope/scope.h'
41--- include/youtube/scope/scope.h 2014-09-12 16:29:32 +0000
42+++ include/youtube/scope/scope.h 2014-10-13 12:17:24 +0000
43@@ -27,6 +27,8 @@
44 #include <unity/scopes/ReplyProxyFwd.h>
45 #include <unity/scopes/ScopeBase.h>
46
47+#include <condition_variable>
48+
49 namespace youtube {
50
51 namespace scope {
52@@ -50,6 +52,7 @@
53 protected:
54 youtube::api::Config::Ptr config_;
55 std::mutex config_mutex_;
56+ std::condition_variable config_cond_;
57 std::shared_ptr<unity::scopes::OnlineAccountClient> oa_client_;
58 };
59
60
61=== modified file 'src/youtube/scope/scope.cpp'
62--- src/youtube/scope/scope.cpp 2014-09-15 10:12:11 +0000
63+++ src/youtube/scope/scope.cpp 2014-10-13 12:17:24 +0000
64@@ -63,6 +63,8 @@
65 } else {
66 cerr << "YouTube scope is authenticated" << endl;
67 }
68+
69+ config_cond_.notify_all();
70 }
71
72 void Scope::start(string const&) {
73@@ -73,12 +75,18 @@
74
75 oa_client_.reset(
76 new sc::OnlineAccountClient(SCOPE_INSTALL_NAME,
77- "sharing", "google",
78- sc::OnlineAccountClient::CreateInternalMainLoop));
79+ "sharing", "google"));
80 oa_client_->set_service_update_callback(
81 std::bind(&Scope::service_update, this, std::placeholders::_1));
82
83- update_config();
84+ // Allow 2 seconds for the callback to initialize config_
85+ std::unique_lock<std::mutex> lock(config_mutex_);
86+ config_cond_.wait_for(lock, std::chrono::seconds(2), [this] { return config_ != nullptr; });
87+ if (config_ == nullptr)
88+ {
89+ // If the callback was not invoked, default initialize config_
90+ config_ = make_shared<Config>();
91+ }
92 }
93
94 void Scope::stop() {

Subscribers

People subscribed via source and target branches