~ci-train-bot/thumbnailer/thumbnailer-ubuntu-yakkety-landing-072

« back to all changes in this revision

Viewing changes to src/service/dbusinterface.cpp

  • Committer: CI Train Bot
  • Author(s): Michi Henning
  • Date: 2015-09-15 11:04:11 UTC
  • mfrom: (125.1.2 landing150915)
  • Revision ID: ci-train-bot@canonical.com-20150915110411-233xw0fljaq7p2o0
Landing changes on devel to trunk.
Approved by: James Henstridge

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include "dbusinterface.h"
20
20
 
21
21
#include <internal/file_io.h>
22
 
#include <internal/trace.h>
23
22
 
24
23
#include <boost/algorithm/string.hpp>
25
24
#include <boost/regex.hpp>
128
127
 
129
128
}
130
129
 
131
 
DBusInterface::DBusInterface(shared_ptr<Thumbnailer> const& thumbnailer, QObject* parent)
 
130
DBusInterface::DBusInterface(shared_ptr<Thumbnailer> const& thumbnailer,
 
131
                             InactivityHandler& inactivity_handler,
 
132
                             QObject* parent)
132
133
    : QObject(parent)
133
134
    , thumbnailer_(thumbnailer)
 
135
    , inactivity_handler_(inactivity_handler)
134
136
    , check_thread_pool_(make_shared<QThreadPool>())
135
137
    , create_thread_pool_(make_shared<QThreadPool>())
136
138
    , download_limiter_(settings_.max_downloads())
180
182
        auto request = thumbnailer_->get_album_art(artist.toStdString(), album.toStdString(), requestedSize);
181
183
        queueRequest(new Handler(connection(), message(),
182
184
                                 check_thread_pool_, create_thread_pool_,
183
 
                                 download_limiter_, credentials(),
 
185
                                 download_limiter_, credentials(), inactivity_handler_,
184
186
                                 std::move(request), details));
185
187
    }
186
188
    // LCOV_EXCL_START
206
208
        auto request = thumbnailer_->get_artist_art(artist.toStdString(), album.toStdString(), requestedSize);
207
209
        queueRequest(new Handler(connection(), message(),
208
210
                                 check_thread_pool_, create_thread_pool_,
209
 
                                 download_limiter_, credentials(),
 
211
                                 download_limiter_, credentials(), inactivity_handler_,
210
212
                                 std::move(request), details));
211
213
    }
212
214
    // LCOV_EXCL_START
230
232
        QString details;
231
233
        QTextStream s(&details);
232
234
        s << "thumbnail: " << filename << " (" << requestedSize.width() << "," << requestedSize.height() << ")";
 
235
 
233
236
        auto request = thumbnailer_->get_thumbnail(filename.toStdString(), requestedSize);
234
237
        queueRequest(new Handler(connection(), message(),
235
238
                                 check_thread_pool_, create_thread_pool_,
236
 
                                 *extraction_limiter_, credentials(),
 
239
                                 *extraction_limiter_, credentials(), inactivity_handler_,
237
240
                                 std::move(request), details));
238
241
    }
239
242
    catch (exception const& e)
248
251
void DBusInterface::queueRequest(Handler* handler)
249
252
{
250
253
    requests_.emplace(handler, std::unique_ptr<Handler>(handler));
251
 
    Q_EMIT endInactivity();
252
254
    connect(handler, &Handler::finished, this, &DBusInterface::requestFinished);
253
255
    setDelayedReply(true);
254
256
 
264
266
        /* There are other requests for this item, so chain this
265
267
         * request to wait for them to complete first.  This way we
266
268
         * can take advantage of any cached downloads or failures. */
267
 
        // TODO: should record tiem spent in queue
 
269
        // TODO: should record time spent in queue
268
270
        connect(requests_for_key.back(), &Handler::finished,
269
271
                handler, &Handler::begin);
270
272
    }
297
299
        request_keys_.erase(handler->key());
298
300
    }
299
301
 
300
 
    if (requests_.empty())
301
 
    {
302
 
        Q_EMIT startInactivity();
303
 
    }
304
302
    // Queue deletion of handler when we re-enter the event loop.
305
303
    handler->deleteLater();
306
304