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
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-09-16 10:39:19 +0000
+++ CMakeLists.txt 2014-10-13 12:17:24 +0000
@@ -27,7 +27,7 @@
27 SCOPE27 SCOPE
28 glib-2.028 glib-2.0
29 gio-unix-2.029 gio-unix-2.0
30 libunity-scopes>=0.6.630 libunity-scopes>=0.6.7
31 jsoncpp31 jsoncpp
32 net-cpp>=1.1.032 net-cpp>=1.1.0
33 process-cpp33 process-cpp
3434
=== modified file 'debian/control'
--- debian/control 2014-09-16 11:40:39 +0000
+++ debian/control 2014-10-13 12:17:24 +0000
@@ -15,7 +15,7 @@
15 libjsoncpp-dev,15 libjsoncpp-dev,
16 libnet-cpp-dev (>= 1.1.0),16 libnet-cpp-dev (>= 1.1.0),
17 libprocess-cpp-dev,17 libprocess-cpp-dev,
18 libunity-scopes-dev (>= 0.6.6),18 libunity-scopes-dev (>= 0.6.7),
19 pkg-config,19 pkg-config,
20 python-tornado,20 python-tornado,
21Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>21Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
2222
=== modified file 'include/youtube/api/config.h'
--- include/youtube/api/config.h 2014-08-11 10:35:09 +0000
+++ include/youtube/api/config.h 2014-10-13 12:17:24 +0000
@@ -63,7 +63,7 @@
63 */63 */
64 std::string accept {"application/json"};64 std::string accept {"application/json"};
6565
66 /**66 /*
67 * Have we got access to private APIs?67 * Have we got access to private APIs?
68 */68 */
69 bool authenticated = false;69 bool authenticated = false;
7070
=== modified file 'include/youtube/scope/scope.h'
--- include/youtube/scope/scope.h 2014-09-12 16:29:32 +0000
+++ include/youtube/scope/scope.h 2014-10-13 12:17:24 +0000
@@ -27,6 +27,8 @@
27#include <unity/scopes/ReplyProxyFwd.h>27#include <unity/scopes/ReplyProxyFwd.h>
28#include <unity/scopes/ScopeBase.h>28#include <unity/scopes/ScopeBase.h>
2929
30#include <condition_variable>
31
30namespace youtube {32namespace youtube {
3133
32namespace scope {34namespace scope {
@@ -50,6 +52,7 @@
50protected:52protected:
51 youtube::api::Config::Ptr config_;53 youtube::api::Config::Ptr config_;
52 std::mutex config_mutex_;54 std::mutex config_mutex_;
55 std::condition_variable config_cond_;
53 std::shared_ptr<unity::scopes::OnlineAccountClient> oa_client_;56 std::shared_ptr<unity::scopes::OnlineAccountClient> oa_client_;
54};57};
5558
5659
=== modified file 'src/youtube/scope/scope.cpp'
--- src/youtube/scope/scope.cpp 2014-09-15 10:12:11 +0000
+++ src/youtube/scope/scope.cpp 2014-10-13 12:17:24 +0000
@@ -63,6 +63,8 @@
63 } else {63 } else {
64 cerr << "YouTube scope is authenticated" << endl;64 cerr << "YouTube scope is authenticated" << endl;
65 }65 }
66
67 config_cond_.notify_all();
66}68}
6769
68void Scope::start(string const&) {70void Scope::start(string const&) {
@@ -73,12 +75,18 @@
7375
74 oa_client_.reset(76 oa_client_.reset(
75 new sc::OnlineAccountClient(SCOPE_INSTALL_NAME,77 new sc::OnlineAccountClient(SCOPE_INSTALL_NAME,
76 "sharing", "google",78 "sharing", "google"));
77 sc::OnlineAccountClient::CreateInternalMainLoop));
78 oa_client_->set_service_update_callback(79 oa_client_->set_service_update_callback(
79 std::bind(&Scope::service_update, this, std::placeholders::_1));80 std::bind(&Scope::service_update, this, std::placeholders::_1));
8081
81 update_config();82 // Allow 2 seconds for the callback to initialize config_
83 std::unique_lock<std::mutex> lock(config_mutex_);
84 config_cond_.wait_for(lock, std::chrono::seconds(2), [this] { return config_ != nullptr; });
85 if (config_ == nullptr)
86 {
87 // If the callback was not invoked, default initialize config_
88 config_ = make_shared<Config>();
89 }
82}90}
8391
84void Scope::stop() {92void Scope::stop() {

Subscribers

People subscribed via source and target branches