Mir

Merge lp://qastaging/~mir-team/mir/public-cookie-api into lp://qastaging/mir

Proposed by Brandon Schaefer
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3269
Proposed branch: lp://qastaging/~mir-team/mir/public-cookie-api
Merge into: lp://qastaging/mir
Diff against target: 4380 lines (+1209/-588)
103 files modified
3rd_party/CMakeLists.txt (+1/-0)
3rd_party/android-input/android/frameworks/base/include/androidfw/Input.h (+8/-6)
3rd_party/android-input/android/frameworks/base/include/androidfw/InputTransport.h (+4/-4)
3rd_party/android-input/android/frameworks/base/services/input/Input.cpp (+6/-6)
3rd_party/android-input/android/frameworks/base/services/input/InputTransport.cpp (+10/-10)
debian/control (+2/-2)
debian/libmircookie2.install (+1/-1)
include/client/mir/events/event_builders.h (+21/-3)
include/client/mir_toolkit/events/event.h (+2/-0)
include/client/mir_toolkit/events/input/input_event.h (+18/-1)
include/client/mir_toolkit/mir_client_library.h (+1/-0)
include/client/mir_toolkit/mir_cookie.h (+71/-0)
include/client/mir_toolkit/mir_surface.h (+9/-0)
include/cookie/mir/cookie/authority.h (+57/-50)
include/cookie/mir/cookie/cookie.h (+57/-0)
include/server/mir/server.h (+4/-4)
include/server/mir/shell/abstract_shell.h (+1/-1)
include/server/mir/shell/shell.h (+1/-1)
include/server/mir/shell/shell_wrapper.h (+1/-1)
src/client/CMakeLists.txt (+3/-1)
src/client/events/event_builders.cpp (+62/-13)
src/client/input/android/android_input_lexicon.cpp (+7/-3)
src/client/input/input_event.cpp (+97/-1)
src/client/mir_cookie.cpp (+49/-0)
src/client/mir_cookie.h (+40/-0)
src/client/mir_surface.cpp (+5/-5)
src/client/mir_surface.h (+1/-2)
src/client/mir_surface_api.cpp (+2/-3)
src/client/rpc/mir_display_server.cpp (+1/-1)
src/client/rpc/mir_display_server.h (+1/-1)
src/client/symbols.map (+7/-0)
src/cookie/CMakeLists.txt (+5/-3)
src/cookie/authority.cpp (+97/-32)
src/cookie/format.h (+35/-0)
src/cookie/hmac_cookie.cpp (+53/-0)
src/cookie/hmac_cookie.h (+51/-0)
src/cookie/symbols.map (+5/-5)
src/include/common/mir/events/event_private.h (+4/-4)
src/include/common/mir/protobuf/display_server.h (+1/-1)
src/include/cookie/mir/cookie/blob.h (+19/-30)
src/include/server/mir/default_server_configuration.h (+3/-3)
src/include/server/mir/frontend/security_check_failed.h (+0/-34)
src/include/server/mir/frontend/shell.h (+1/-1)
src/include/server/mir/frontend/template_protobuf_message_processor.h (+2/-2)
src/include/server/mir/server_configuration.h (+2/-2)
src/protobuf/mir_protobuf.proto (+1/-2)
src/server/CMakeLists.txt (+1/-0)
src/server/default_server_configuration.cpp (+5/-5)
src/server/frontend/CMakeLists.txt (+0/-1)
src/server/frontend/default_configuration.cpp (+1/-1)
src/server/frontend/default_ipc_factory.cpp (+4/-4)
src/server/frontend/default_ipc_factory.h (+3/-3)
src/server/frontend/protobuf_message_processor.cpp (+4/-4)
src/server/frontend/security_check_failed.cpp (+0/-24)
src/server/frontend/session_mediator.cpp (+10/-10)
src/server/frontend/session_mediator.h (+4/-4)
src/server/frontend/shell_wrapper.cpp (+2/-2)
src/server/frontend/shell_wrapper.h (+1/-1)
src/server/input/android/input_sender.cpp (+3/-3)
src/server/input/default_configuration.cpp (+3/-3)
src/server/input/default_event_builder.cpp (+18/-11)
src/server/input/default_event_builder.h (+3/-3)
src/server/input/default_input_device_hub.cpp (+6/-6)
src/server/input/default_input_device_hub.h (+4/-4)
src/server/input/key_repeat_dispatcher.cpp (+7/-4)
src/server/input/key_repeat_dispatcher.h (+3/-3)
src/server/input/surface_input_dispatcher.cpp (+1/-2)
src/server/input/validator.cpp (+1/-1)
src/server/server.cpp (+2/-2)
src/server/shell/abstract_shell.cpp (+1/-1)
src/server/shell/frontend_shell.cpp (+2/-2)
src/server/shell/frontend_shell.h (+1/-1)
src/server/shell/shell_wrapper.cpp (+2/-2)
src/server/symbols.map (+6/-6)
tests/acceptance-tests/test_client_cookie.cpp (+72/-47)
tests/acceptance-tests/test_client_input.cpp (+1/-1)
tests/acceptance-tests/test_surface_modifications.cpp (+3/-4)
tests/acceptance-tests/test_surface_placement.cpp (+1/-2)
tests/acceptance-tests/test_surface_raise.cpp (+83/-54)
tests/acceptance-tests/test_surface_specification.cpp (+3/-4)
tests/include/mir/test/doubles/mock_shell.h (+1/-1)
tests/include/mir/test/doubles/stub_display_server.h (+1/-1)
tests/integration-tests/CMakeLists.txt (+1/-0)
tests/integration-tests/input/test_single_seat_setup.cpp (+3/-3)
tests/mir_test_doubles/CMakeLists.txt (+1/-0)
tests/unit-tests/CMakeLists.txt (+1/-0)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+2/-2)
tests/unit-tests/client/input/test_xkb_mapper.cpp (+1/-2)
tests/unit-tests/frontend/test_event_sender.cpp (+1/-2)
tests/unit-tests/frontend/test_session_mediator.cpp (+10/-11)
tests/unit-tests/input/android/test_android_input_lexicon.cpp (+7/-10)
tests/unit-tests/input/android/test_android_input_sender.cpp (+8/-13)
tests/unit-tests/input/evdev/test_libinput_device.cpp (+3/-3)
tests/unit-tests/input/test_default_input_device_hub.cpp (+3/-3)
tests/unit-tests/input/test_event_builders.cpp (+7/-12)
tests/unit-tests/input/test_event_filter_chain_dispatcher.cpp (+1/-1)
tests/unit-tests/input/test_key_repeat_dispatcher.cpp (+5/-5)
tests/unit-tests/input/test_surface_input_dispatcher.cpp (+10/-10)
tests/unit-tests/input/test_validator.cpp (+1/-1)
tests/unit-tests/input/test_x11_platform.cpp (+2/-2)
tests/unit-tests/scene/test_abstract_shell.cpp (+4/-4)
tests/unit-tests/scene/test_surface.cpp (+2/-2)
tests/unit-tests/test_mir_cookie.cpp (+44/-36)
To merge this branch: bzr merge lp://qastaging/~mir-team/mir/public-cookie-api
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Abstain
Mir CI Bot continuous-integration Approve
Andreas Pokorny (community) Approve
Alexandros Frantzis (community) Needs Fixing
Alberto Aguirre (community) Approve
Chris Halse Rogers Approve
Daniel van Vugt Abstain
Kevin DuBois (community) Approve
Review via email: mp+282279@code.qastaging.launchpad.net

Commit message

Re-add support for get a MirCookie as well as Raising a surface with a MirCookie.

The MirCookie structure is now opaque.

Description of the change

Re-add support for get a MirCookie as well as Raising a surface with a MirCookie.

The MirCookie structure is now opaque.

Different APIs we have considered:
https://pastebin.canonical.com/147720/

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Should the mir_input_event_get_cookie use MirCookie* or just a uint8_t* (or char*?)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3243
https://mir-jenkins.ubuntu.com/job/mir-ci/31/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/31/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/31/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

> Should the mir_input_event_get_cookie use MirCookie* or just a uint8_t* (or
> char*?)

my vote is MirCookie*

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

After ROAF and I talking for a bit we settled on void* since we are send a stream of *unknown* bytes. Since not just the mac is being sent, so is the timestamp

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3244
https://mir-jenkins.ubuntu.com/job/mir-ci/45/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/45/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/45/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

The Story Of The Void*:
Brandon and I had a *long* back and forth about client API wrt MirCookie, ranging from having a MirCookie type that can be converted into a MirBlob, to essentially duplicating MirBlob's API against a MirCookie, to a non-opaque struct MirCookie { size_t length, void* data };

Neither of us were particularly happy with any of them.

The void* API here is (a) transparent - it's clear to everyone that they've just got a blob of data, (b) quick to implement, and (c) is minimally constraining for future, better, implementations with better APIs.

General comment: I'm pretty sure you don't need reinterpret_cast<> to go between void* and MirCookie*; static_cast<MirCookie*> should be sufficient. (Wheras you *do* need to reinterpret_cast between uint8_t* and uint64_t*)

42 + * \params[in] ev The input event
43 + * \params[in] cookie An allocated void* with exactly cookie_size bytes
44 + * \params[in] size The size of the MirCookie
45 + */
46 +void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie, size_t size);

Two things: do we need to pass size in here? We're only going to assert that it's exactly mir_input_event_get_cookie_size(), right?

And: If we do keep the size, you need to update the comment; no MirCookie here ☺.

Also a couple of inline comments.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3245
https://mir-jenkins.ubuntu.com/job/mir-ci/46/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/46/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/46/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3246
https://mir-jenkins.ubuntu.com/job/mir-ci/47/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/47/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/47/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

not too flummoxed about use of void*, especially if you & Chris gave it more thought than I had behind my comment. Some other things that I'm not too flummoxed about (esp given that (as I understand) this is needed in short order)

+ auto const* pev = mir_input_event_get_pointer_event(ev);
no need for * (a few other places)

+ // FIXME Moveing to 160bits soon
typo

+ void* cookie = malloc(size);
would be a bit better to use a RAII type in allocation for this test (and would eliminate the need for a destructor too)

768: std::mutex mutex;
A bit strange to have the mutex be public, and require locking it before accessing some members. Would be better encapsulated to have functions on the object to do that.

review: Approve
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> not too flummoxed about use of void*, especially if you & Chris gave it more
> thought than I had behind my comment. Some other things that I'm not too
> flummoxed about (esp given that (as I understand) this is needed in short
> order)
>
> + auto const* pev = mir_input_event_get_pointer_event(ev);
> no need for * (a few other places)

I was mainly doing that so you can see its a pointer (I like seeing types sometimes), but yeah auto captures that :). Fixed.

>
> + // FIXME Moveing to 160bits soon
> typo
>

Opps. Fixed.

> + void* cookie = malloc(size);
> would be a bit better to use a RAII type in allocation for this test (and
> would eliminate the need for a destructor too)
Yes! I attempted it but ran into issue when I was using the MirCookie* since the size was not known (should have just written my own destructor for the shared_ptr to cast and delete[].) Fixed.

>
> 768: std::mutex mutex;
> A bit strange to have the mutex be public, and require locking it before
> accessing some members. Would be better encapsulated to have functions on the
> object to do that.

Agreed, and it looks much cleaner :). Fixed.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

There's stuff I'm concerned about, but I'm out of time today to review properly - will get to it first thing tomorrow.

review: Abstain
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

(pushing coming in a few :)

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

void* is an incomplete type, soo to put it into a shared/unique ptr fails on a static_assert. I suppose for testing i could just cast it to a uint8_t, since its in bytes... or just leave it with a malloc/free :)

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3247
https://mir-jenkins.ubuntu.com/job/mir-ci/58/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/58/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/58/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3249
https://mir-jenkins.ubuntu.com/job/mir-ci/59/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/59/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/59/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Bunch of locking issues still in the tests; marked inline.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3250
https://mir-jenkins.ubuntu.com/job/mir-ci/60/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/60/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/60/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3251
https://mir-jenkins.ubuntu.com/job/mir-ci/61/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/61/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/61/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Different APIs we have considered:
https://pastebin.canonical.com/147720/

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3250
http://jenkins.qa.ubuntu.com/job/mir-ci/6025/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5541
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4448
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5497
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/281
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/349
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/349/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/349
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/349/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5494
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5494/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7964
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26690
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/277
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/277/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/135
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26691

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6025/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

566 + void handle_input_event(MirInputEvent const* iev)
567 + {
568 + std::lock_guard<std::mutex> lk(mutex);
569 + if (mir_input_event_has_cookie(iev))
570 + {
571 + auto const size = mir_input_event_get_cookie_size(iev);
572 + std::vector<uint8_t> cookie(size);
573 +
574 + mir_input_event_copy_cookie(iev, cookie.data());
575 + out_cookies.push_back(cookie);
576 + }
577 +
578 + event_count++;
579 + }
580 +
581 + size_t get_event_count() const
582 + {
583 + std::lock_guard<std::mutex> lk(mutex);
584 + return event_count;
585 + }
586 +
587 + size_t cookie_size() const
588 + {
589 + std::lock_guard<std::mutex> lk(mutex);
590 + return out_cookies.size();
591 + }
592 +
593 + std::vector<uint8_t> back_cookie() const
594 + {
595 + std::lock_guard<std::mutex> lk(mutex);
596 + return out_cookies.back();
597 + }
598 +
599 + bool cookies_empty() const
600 + {
601 + std::lock_guard<std::mutex> lk(mutex);
602 + return out_cookies.empty();
603 + }

While not blocking, this seems to be a bit of a faff for the testcase vs just directly locking the mutex when necessary :).

Otherwise, I'm OK, pending possible API changes :)

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3252
https://mir-jenkins.ubuntu.com/job/mir-ci/63/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/63/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/63/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3253
https://mir-jenkins.ubuntu.com/job/mir-ci/64/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/64/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/64/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3252
http://jenkins.qa.ubuntu.com/job/mir-ci/6027/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5543
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4450
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5499
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/283
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/351
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/351/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/351
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/351/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5496
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5496/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7966
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26694
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/279
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/279/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/137
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26695

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6027/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Oh, whoops! Missed one thing, sorry.

This would appear to be a libmircookie ABI break, so should be accompanied by a SONAME bump.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3254
https://mir-jenkins.ubuntu.com/job/mir-ci/65/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/65/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/65/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3253
http://jenkins.qa.ubuntu.com/job/mir-ci/6028/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5544
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4451
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5500
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/284
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/352
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/352/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/352
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/352/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5497
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5497/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7967
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26696
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/280
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/280/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/138
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26697

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6028/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

+ typedef struct MirCookie MirCookie;

Not needed (at the moment at least), and also may conflict with mir::cookie::MirCookie.

- virtual MirCookie timestamp_to_cookie(uint64_t const& timestamp) = 0;

A *Cookie*Factory that doesn't create cookies seems strange.

Needs discussion/fixing

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3255
https://mir-jenkins.ubuntu.com/job/mir-ci/66/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/66/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/66/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+// FIXME Remove me when we are no longer returning 8 byte MACS
+// We assert that what we return is 8 bytes, so lets test for that for now!
+TEST(MirCookieFactory, assert_8_bytes_for_mac)
+{
+ std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
+ auto factory = mir::cookie::CookieFactory::create_from_secret(secret);
+ uint64_t mock_timestamp{0x322322322332};
+ auto mac = factory->timestamp_to_mac(mock_timestamp);
+
+ EXPECT_EQ(mac.size(), sizeof(uint64_t));
+}

sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit characters are of little interest to us.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Nits to fix and questions:

CookieFactory looks less and less like a "factory" interface. Would "CookieAuthority" be a better name?

~~~~

+ virtual bool attest_timestamp(MirCookie const* cookie) = 0;

This is the only place in the interface MirCookie is mentioned. Should we simply lose this function and require the user to call the other overload?

~~~~

+void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie);

I'm always cautions of APIs that take a target buffer and no buffer size - while not bulletproof the latter is at least a reminder to the user to obtain the size.

~~~~

+void mir_surface_raise_with_cookie(MirSurface* surface, void const* cookie);

By using void* we loose the type safety that we have with other Mir APIs. Can you provide some justification for this design choice? E.g. will this function be primarily for clients that obtained the cookie from a non-Mir API?

~~~~

- * Copyright © 2015 Canonical Ltd.
+ * Copyright © 2016 Canonical Ltd.

Don't remove the 2015 copyright claim. (I know these headers are legally unnecessary and PITA, but let's try to do it right.)

~~~~

+ /* No mac == no size! */
+ return 0;

It should be a precondition that there's a MAC. I.e. the function should begin with something like:

    mir::require(mir_input_event_has_cookie(ev));

~~~~

+#include "mir/cookie.h"
#include "mir/cookie_factory.h"

The first include of the source file should be the corresponding header (to ensure it compiles by itself).

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3255
http://jenkins.qa.ubuntu.com/job/mir-ci/6030/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5547
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4454
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5503
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/285
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/354
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/354/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/354
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/354/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5500
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5500/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7969
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26699
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/281
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/281/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/139
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26703

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6030/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +// FIXME Remove me when we are no longer returning 8 byte MACS
> +// We assert that what we return is 8 bytes, so lets test for that for now!
> +TEST(MirCookieFactory, assert_8_bytes_for_mac)
> +{
> + std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde,
> 0x01 };
> + auto factory = mir::cookie::CookieFactory::create_from_secret(secret);
> + uint64_t mock_timestamp{0x322322322332};
> + auto mac = factory->timestamp_to_mac(mock_timestamp);
> +
> + EXPECT_EQ(mac.size(), sizeof(uint64_t));
> +}
>
> sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit
> characters are of little interest to us.

Hmm should I just not assert this then? Since really all im assert is that our mac == sizeof(uint64_t). So possibly I should just change the name.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> Nits to fix and questions:
>
> CookieFactory looks less and less like a "factory" interface. Would
> "CookieAuthority" be a better name?
>
> ~~~~

Agreed.

>
> + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
>
> This is the only place in the interface MirCookie is mentioned. Should we
> simply lose this function and require the user to call the other overload?
>
> ~~~~

The reason for keeping this, is theres no way to de construct a MirCookie in the public. So once the content hub gets a mir cookie it wont know how to *attest* it.

>
> +void mir_input_event_copy_cookie(MirInputEvent const* ev, void* cookie);
>
> I'm always cautions of APIs that take a target buffer and no buffer size -
> while not bulletproof the latter is at least a reminder to the user to obtain
> the size.
>
> ~~~~

Thats sounds quite reasonable to me.
>
> +void mir_surface_raise_with_cookie(MirSurface* surface, void const* cookie);
>
> By using void* we loose the type safety that we have with other Mir APIs. Can
> you provide some justification for this design choice? E.g. will this
> function be primarily for clients that obtained the cookie from a non-Mir API?
>
> ~~~~

I agree, and will be switching to a MirCookie* for both the copy and these functions since void* and MirCookie* will both be incomplete types.

>
> - * Copyright © 2015 Canonical Ltd.
> + * Copyright © 2016 Canonical Ltd.
>
> Don't remove the 2015 copyright claim. (I know these headers are legally
> unnecessary and PITA, but let's try to do it right.)
>
> ~~~~

Opps. Yeah Ill fix those!

>
> + /* No mac == no size! */
> + return 0;
>
> It should be a precondition that there's a MAC. I.e. the function should begin
> with something like:
>
> mir::require(mir_input_event_has_cookie(ev));
>
> ~~~~

This is true, if we have a function that tells you if an event has a cookie we better require it to actually have one when attempting to construct it!.

>
> +#include "mir/cookie.h"
> #include "mir/cookie_factory.h"
>
> The first include of the source file should be the corresponding header (to
> ensure it compiles by itself).

Will fix!

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> + typedef struct MirCookie MirCookie;
>
> Not needed (at the moment at least), and also may conflict with
> mir::cookie::MirCookie.

Opps thought I removed all thoses... Had an idea at one point that I think made it into a file :)
>
> - virtual MirCookie timestamp_to_cookie(uint64_t const& timestamp) = 0;
>
> A *Cookie*Factory that doesn't create cookies seems strange.
>
> Needs discussion/fixing

Right it doesnt create any MirCookies but it creates what a cookie is. With alans comment, changing the name to:
CookieAuthority

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > sizeof(uint64_t) is not a synonym for 8 - although platforms with 16bit
> > characters are of little interest to us.
>
> Hmm should I just not assert this then? Since really all im assert is that our
> mac == sizeof(uint64_t). So possibly I should just change the name.

On reflection, if unit8_t exists we're safe to assume 8 bit chars. (And if it doesn't we don't compile.)

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
> >
> > This is the only place in the interface MirCookie is mentioned. Should we
> > simply lose this function and require the user to call the other overload?
> >
> > ~~~~
>
> The reason for keeping this, is theres no way to de construct a MirCookie in
> the public. So once the content hub gets a mir cookie it wont know how to
> *attest* it.

are you conflating ::MirCookie and mir::cookie::MirCookie?

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> > > + virtual bool attest_timestamp(MirCookie const* cookie) = 0;
> > >
> > > This is the only place in the interface MirCookie is mentioned. Should we
> > > simply lose this function and require the user to call the other overload?
> > >
> > > ~~~~
> >
> > The reason for keeping this, is theres no way to de construct a MirCookie in
> > the public. So once the content hub gets a mir cookie it wont know how to
> > *attest* it.
>
> are you conflating ::MirCookie and mir::cookie::MirCookie?

Well only mir::cookie::MirCookie should be used? The attest_timestamp is in the mir::cookie namespace. Not sure if they are different and being combined? I Could be wrong :)

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Though there will be an issue... if i move from a void* to a MirCookie* in the public API... not sure how to combine a MirCookie* into a mir::cookie::MirCookie*? Just cast it? I would like a MirCookie* vs void* :)

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3258
https://mir-jenkins.ubuntu.com/job/mir-ci/69/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/69/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/69/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Some concerns addressed. Abstaining until I have time to review again.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3259
https://mir-jenkins.ubuntu.com/job/mir-ci/71/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/71/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/71/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3259
http://jenkins.qa.ubuntu.com/job/mir-ci/6034/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5555
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4462
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5511
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/287
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/358
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/358/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/358
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/358/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5508
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5508/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/7973
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26718
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/283
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/283/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/140
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26720

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6034/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+/*
+ *
+ * \params[in] ev The input event
+ * \params[in] cookie An allocated void* with exactly cookie_size bytes
+ * \params[in] size The size of the allocated void*
+ */
+void mir_input_event_copy_cookie(MirInputEvent const* ev, MirCookie* cookie, size_t size);

When comments and code disagree, both are likely wrong.

While I'm not sure I fully understand the intended usage I suspect that have two scenarios:

1. Getting a MirCookie from an event.
2. Converting a MirCookie to and from a chunk of memory.

In neither of these does it make sense for a user to supply allocate and supply a pointer to an incomplete type.

How about:

MirCookie* mir_input_event_get_cookie(MirInputEvent const* ev);

and either:

MirCookie* mir_blob_to_mir_cookie(MirBlob* blob);
MirBlob* mir_blob_from_mir_cookie(MirCookie* cookie);

Or:

size_t mir_cookie_get_buffer_size(MirCookie* cookie);
void mir_cookie_to_buffer(MirCookie* cookie, void* buffer, size_t size);
MirCookie* mir_cookie_from_buffer(void const* buffer, size_t size);

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

[Just comment]

It (still) seems odd that CookieAuthority deals with both MirCookies and with pairs of timestamp and MAC. Surely a /cookie/ authority should deal with Cookies? Would it not make more sense as:

auto make_cookie(Timestamp t) -> unique_ptr<MirCookie>

auto authenticated_timestamp(MirCookie const& c) -> Timestamp

Having clients aware of the MAC seems like a leaky abstraction

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3261
https://mir-jenkins.ubuntu.com/job/mir-ci/89/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/89/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/89/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3262
https://mir-jenkins.ubuntu.com/job/mir-ci/91/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/90/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/91/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3263
https://mir-jenkins.ubuntu.com/job/mir-ci/92/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/92/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/92/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3264
https://mir-jenkins.ubuntu.com/job/mir-ci/93/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/93/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/93/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3265
https://mir-jenkins.ubuntu.com/job/mir-ci/95/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/95/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/95/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3266
https://mir-jenkins.ubuntu.com/job/mir-ci/96/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/96/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/96/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

394 +/* Returns an allocated MirCookie that you must release with mir_cookie_release
394 + *
395 + * \params[in] ev The input event
396 + * \return An allocated and ref'ed cookie
397 + */

There's no need to say “allocated” or “ref'ed” here.

394 +/* Returns the MirCookie associated with this input event.
394 + *
395 + * \params[in] ev The input event
396 + * \return A reference to the MirCookie associated with this input event.
397 + * This must be released with a call to mir_cookie_release().
398 + */

Likewise:
415 +/* Turns the user copyed buffer back into a MirCookie, which must be
416 + * released with mir_cookie_release
417 + *
418 + * \params[in] buffer The buffer used to get a MirCookie back
419 + * \return A newely allocated MirCookie
420 + */
421 +MirCookie const* mir_cookie_from_buffer(void const* buffer);

should maybe be:
415 +/* Create a MirCookie from a serialised representation.
417 + *
418 + * \params[in] buffer The buffer containing a serialised MirCookie.
418 + * The buffer may be freed immediately after this call.
419 + * \return A reference to a MirCookie.
418 + * This must be released with a call to mir_cookie_release().
420 + */
421 +MirCookie const* mir_cookie_from_buffer(void const* buffer);

This can never return NULL, right?

Actually: we should probably pass in the length of the buffer here and return NULL if it doesn't match what we expect. Clients will get this passed in from other sources, and it'll courteous to tell them if it's easy to detect that it's wrong.

443 +* \param [in] cookie The void* from the input event that you want to raise the window from.
Ba baw!

1143 + mir_surface_raise_with_cookie;
1144 + mir_input_event_has_cookie;
1145 + mir_cookie_get_size;
1146 + mir_input_event_get_cookie;
1147 + mir_cookie_copy_to_buffer;
1148 + mir_cookie_from_buffer;
1149 + mir_cookie_release;

These should be in MIR_CLIENT_unreleased, not MIR_CLIENT_DETAIL (which is pseudo-private implementation details).

+ if (raw_cookie.size() < cookie_size_from_format(mir::cookie::Format::HMAC_SHA_1_8))

Should be !=, right?

Why did you move mir::SecurityCheckFailed?

2029 + auto const& cookie_ptr = cookie_authority->unmarshall_cookie(cookie_bytes);

I'm surprised this passed valgrind? unmarshall_cookie() returns a std::unique_ptr<>, that you take a *reference* to, and then the std::unique_ptr<> gets *destroyed* at the end of the statement.

Likewise in a bunch of other places. Why doesn't this blow up?

A: http://herbsutter.com/2008/01/01/gotw-88-a-candidate-for-the-most-important-const/. I wonder why people think C++ is needlessly arcane‽.

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3267
https://mir-jenkins.ubuntu.com/job/mir-ci/104/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/104/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/104/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3267
https://mir-jenkins.ubuntu.com/job/mir-ci/106/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/106/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/106/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

First pass - cosmetic stuff

+/* Returns an allocated MirCookie that you must release with mir_cookie_release
+ *
+ * \params[in] ev The input event
+ * \return An allocated and ref'ed cookie
+ */
+MirCookie const* mir_input_event_get_cookie(MirInputEvent const* ev);

1. The /precondition/ that the event has a cookie is missing.

2. "An allocated and ref'ed cookie" is implementation detail the user isn't interested in.

~~~~

+ * \return The size needed to allocate a buffer
+ */
+size_t mir_cookie_get_size(MirCookie const* cookie);

While allocation is likely what the client will do, surely this is just the size of buffer needed by mir_cookie_copy_to_buffer().

~~~~

+ * \params[in] buffer The allocated buffer to copy the MirCookie into
+ * \params[in] size The size of the allocated buffer
+ */
+void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size);

%s/allocated //

~~~~

+MirCookie const* mir_cookie_from_buffer(void const* buffer);

I think it would be useful validation for the buffer size to be supplied and checked. While not bulletproof the it is a reminder to the user that size matters.

~~~~

+* \param [in] cookie The void* from the input event that you want to raise the window from.
+*/
+void mir_surface_raise_with_cookie(MirSurface* surface, MirCookie const* cookie);

The comment and the code disagree

~~~~

+ HMAC_SHA_1_8

Is there a reason for the non standard naming style? https://unity.ubuntu.com/mir/cppguide/index.html?showone=Enumerator_Names#Enumerator_Names

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3270
https://mir-jenkins.ubuntu.com/job/mir-ci/110/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/110/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/110/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

From what I've been hearing, I think the terms "cookie" and "marshalling" are over-abstracting the situation. It's better to use more concrete nouns and verbs so the reader more easily understands what's going on. But this is not a review.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3271
https://mir-jenkins.ubuntu.com/job/mir-ci/113/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/113/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/113/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3272
https://mir-jenkins.ubuntu.com/job/mir-ci/114/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/114/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/114/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3273
https://mir-jenkins.ubuntu.com/job/mir-ci/116/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/116/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/116/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3272
http://jenkins.qa.ubuntu.com/job/mir-ci/6093/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5633
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4540
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5589
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/311
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/417
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/417/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/417
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/417/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5586
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5586/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8029
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26885
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/307
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/307/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/163
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26892

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6093/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

Ok, I think. Two inline nonblocking doc comments.

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :
Download full text (7.0 KiB)

Mostly cosmetic things.

mir::cookie::Array => mir::cookie::Blob

Comment suggestions
---
+
386 +/* Tells if the MirInputEvent has a MirCookie
387 + *
388 + * \params[in] ev The input event
389 + * \return True if the input event has a MirCookie
390 + */

change to:

+
386 +/* Query if an input event contains a cookie
387 + *
388 + * \params[in] ev The input event
389 + * \return True if the input event contains a cookie
390 + */

---

---
/* Returns the MirCookie associated with this input event.
 *
 * \pre The input event must have a MirCookie
 * \params[in] ev The input event
 * \return A reference to the MirCookie associated with this input event
 * This must be released with a call to mir_cookie_release()
 */

 change to:

/* Returns the cookie associated with an input event.
 *
 * \pre The input event must have a MirCookie
 * \params[in] ev An input event
 * \return The cookie associated with the given input event
 * The cookie must be released by calling mir_cookie_release
 */
---

/* The size of the buffer needed to serialize this MirCookie
 *
 * \params[in] cookie The MirCookie
 * \return The size needed for a buffer
 */
size_t mir_cookie_get_size(MirCookie const* cookie);

change to:

/* Queries the size needed to serialize a given cookie
 *
 * \params[in] cookie A cookie instance
 * \return The size of the serialized representation of the given cookie
 */
size_t mir_cookie_size(MirCookie const* cookie);
---

---
/* Copy the MirCookie into an allocated buffer
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] cookie The MirCookie
 * \params[in] buffer The allocated buffer to copy the MirCookie into
 * \params[in] size The size of the allocated buffer
 */

 change to:

/* Serializes a cookie into the given buffer
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] cookie A cookie instance
 * \params[in] buffer A buffer which is filled with the serialized representation
                      of the given cookie
 * \params[in] size The size of the given buffer
 */
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size);

To be consistent with mir_cookie_from_buffer
mir_cookie_copy_to_buffer => mir_cookie_to_buffer

---
/* Create a MirCookie from a serialised representation
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] buffer The buffer containing a serialised MirCookie.
 * The buffer may be freed immediately after this call.
 * \return A reference to a MirCookie.
 * This must be released with a call to mir_cookie_release().
 */
MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);

change to:

/* Create a cookie from a serialized representation
 *
 * \pre The size must be equal to mir_cookie_get_size
 * \params[in] buffer The buffer containing a serialized cookie.
 * The buffer may be freed immediately after this call.
 * \return A MirCookie instance. The instance must be re...

Read more...

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+#include "mir/cookie_array.h"

Seeing this caused me to notice an existing issue:

It really ought reflect the "namespace == directory" convention used elsewhere: #include "mir/cookie/array.h"

Not sure if we should fix, or just live with it as "mir/cookie_factory.h" is pre-existing.

review: Needs Information
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Oops on the last one I meant:

---
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size)
{
    mir::require(size == mir::cookie::array_size);
    memcpy(buffer, cookie, size);
}
---

With a client side MirCookie class suggested above would just become:
void mir_cookie_copy_to_buffer(MirCookie const* cookie, void* buffer, size_t size)
{
    return cookie->copy_to(buffer, size);
}

and mir_cookie_release turns into:

+void mir_cookie_release(MirCookie const* cookie)
{
    delete cookie;
}

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3273
http://jenkins.qa.ubuntu.com/job/mir-ci/6100/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5644
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4551
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5600
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/318
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/424
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/424/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/424
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/424/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5597
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5597/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8038
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26908
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/314
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/314/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/170
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26918

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6100/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3276
https://mir-jenkins.ubuntu.com/job/mir-ci/125/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/125/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/125/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3277
https://mir-jenkins.ubuntu.com/job/mir-ci/126/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/126/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/126/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3278
https://mir-jenkins.ubuntu.com/job/mir-ci/127/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/127/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/127/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3279
https://mir-jenkins.ubuntu.com/job/mir-ci/128/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/128/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/128/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM.

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3281
https://mir-jenkins.ubuntu.com/job/mir-ci/130/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/130/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/130/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3285
https://mir-jenkins.ubuntu.com/job/mir-ci/132/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/131/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/132/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+/* Queries the size needed to serialize a given cookie
+ *
+ * \params[in] cookie A cookie instance
+ * \return The size of the serialized representation of the given cookie
+ */
+size_t mir_cookie_size(MirCookie const* cookie);

Would mir_cookie_buffer_size() be a clearer name?

~~~~

+/* Create a cookie from a serialized representation
+ *
+ * \pre The size must be equal to mir_cookie_size
+ * \params[in] buffer The buffer containing a serialized cookie.
+ * The buffer may be freed immediately after this call.
+ * \return A MirCookie instance. The instance must be released
+ with a call to mir_cookie_release.
+ */
+MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);

The precondition is impossible for the client to check - mir_cookie_size() takes a parameter that isn't (in the general case) available to the client.

Perhaps we should drop the cookie parameter from mir_cookie_size()? Or do we expect different cookies to have different sizes?

~~~~

+class Cookie
+{
+public:
+ virtual ~Cookie() = default;
+
+ /**
+ * Returns the timestamp that the cookie is built with
+ *
+ * \return The timestamp
+ */
+ virtual uint64_t timestamp() const = 0;
+
+ /**
+ * Converts the cookie into a stream of bytes.
+ *
+ * \return The stream of bytes formatted
+ */
+ virtual std::vector<uint8_t> serialize() const = 0;
+};

interfaces should delete CopyAssign

~~~~

- void raise_surface_with_timestamp(
+ void raise_surface(

Is this API break necessary? It will break downstreams. (And is how it motivated by the purpose of this MP?)

~~~~

inline mir::cookie::Blob const& getCookie() const { return mCookie; }

so getCookie() returns a blob? Confusing! "getCookieAsBlob()"?

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Non-blocking questions and comments:

mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
                                    kev->getEventTime(),
- kev->getMac(),
+ {std::begin(cookie), std::end(cookie)},
mia::mir_keyboard_action_from_android(kev->getAction(), kev->getRepeatCount()),
                                    kev->getKeyCode(),
kev->getScanCode(),

Why do we need to create a "std::vector<uint8_t>" temporary from a blob (called "cookie"!)? What stops make_event taking a blob const&?

~~~~

+ MirCookie() = delete;

What advantage is there for disabling default construction?

~~~~

+#include "cookie.h"

We usually write the full path in public headers. Vis:

#include "mir/cookie/cookie.h"

~~~~

+ * \return A unique_ptr Authority

I don't think it useful to mention unique_ptr in the doc comment. (And you don't do it consistently.)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3279
http://jenkins.qa.ubuntu.com/job/mir-ci/6108/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5658
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4565
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5614
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/323/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/432
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/432/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/432
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/432/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5611
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5611/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8049
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26943
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/319
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/319/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/175/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26958

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6108/rebuild

review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +/* Queries the size needed to serialize a given cookie
> + *
> + * \params[in] cookie A cookie instance
> + * \return The size of the serialized representation of the given
> cookie
> + */
> +size_t mir_cookie_size(MirCookie const* cookie);
>
> Would mir_cookie_buffer_size() be a clearer name?
>
> ~~~~

Yes it would. Changing.

>
> +/* Create a cookie from a serialized representation
> + *
> + * \pre The size must be equal to mir_cookie_size
> + * \params[in] buffer The buffer containing a serialized cookie.
> + * The buffer may be freed immediately after this call.
> + * \return A MirCookie instance. The instance must be released
> + with a call to mir_cookie_release.
> + */
> +MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size);
>
> The precondition is impossible for the client to check - mir_cookie_size()
> takes a parameter that isn't (in the general case) available to the client.
>
> Perhaps we should drop the cookie parameter from mir_cookie_size()? Or do we
> expect different cookies to have different sizes?
>
> ~~~~

While atm the cookie size is consistent, the cookie size is dependent on the cookie authority implementation.

As far as the size, the size for the buffer *must* be mir_cookie_size() and it *must* get that size to allocate said buffer. The only way they could have gotten an allocated buffer, would be by querying the size. So I would think its up to the user to pass the size_t size around which MUST be equal to the mir_cookie_size at one point.

>
> +class Cookie
> +{
> +public:
> + virtual ~Cookie() = default;
> +
> + /**
> + * Returns the timestamp that the cookie is built with
> + *
> + * \return The timestamp
> + */
> + virtual uint64_t timestamp() const = 0;
> +
> + /**
> + * Converts the cookie into a stream of bytes.
> + *
> + * \return The stream of bytes formatted
> + */
> + virtual std::vector<uint8_t> serialize() const = 0;
> +};
>
> interfaces should delete CopyAssign
>
> ~~~~

Reasonable, Changing.

>
> - void raise_surface_with_timestamp(
> + void raise_surface(
>
> Is this API break necessary? It will break downstreams. (And is how it
> motivated by the purpose of this MP?)
>
> ~~~~

This API is new, (was removed from the API before the 0.18 release). So just trying to get the correct name for it.
>
> inline mir::cookie::Blob const& getCookie() const { return mCookie; }
>
> so getCookie() returns a blob? Confusing! "getCookieAsBlob()"?

Very confusing, and yes Ill go through and rename that.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> Non-blocking questions and comments:
>
> mev::make_event(MirInputDeviceId(android_event->getDeviceId()),
> kev->getEventTime(),
> - kev->getMac(),
> + {std::begin(cookie), std::end(cookie)},
> mia::mir_keyboard_action_from_android(kev->getAction(),
> kev->getRepeatCount()),
> kev->getKeyCode(),
> kev->getScanCode(),
>
> Why do we need to create a "std::vector<uint8_t>" temporary from a blob
> (called "cookie"!)? What stops make_event taking a blob const&?
>
> ~~~~
>

Since blob const& is a std::array<uint8_t, 17> and the event_builder.h is c++ public API. Since its a public API I move back to std::array so we dont depend on a fix size for the cookie.
> + MirCookie() = delete;
>
> What advantage is there for disabling default construction?
>
>
> ~~~~
>
> +#include "cookie.h"
>
> We usually write the full path in public headers. Vis:
>
> #include "mir/cookie/cookie.h"
>
> ~~~~

Makes sesne, and reads better. Changing.

>
> + * \return A unique_ptr Authority
>
> I don't think it useful to mention unique_ptr in the doc comment. (And you
> don't do it consistently.)

Changing.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> MirCookie() = delete;
> What advantage is there for disabling default construction?

Mainly to force the creation of only valid MirCookies. So if we ever get one we know it must have been created through one of its explicit CTOR.

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

From what I see at the ClientCookies fixture. The test body does not wait for the client surface to be exposed and focused. So there is a chance that the SurfaceInputDispatcher does not forward the event to the client. I.e. you could cut some code out of the TestClientInput fixture. CI does not seem to affected by that problem, so you might as well do that some time after the release.

Is there a reason why you do not throw SecurityCheckErrors with BOOST_THROW_EXCEPTION?

review: Needs Information
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3286
https://mir-jenkins.ubuntu.com/job/mir-ci/136/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/136/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/136/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size)
+{
+ if (size != mir::cookie::default_blob_size)
+ return NULL;
+
+ return new MirCookie(buffer, size);
+}

While it is extremely unlikely for operator new() (or any of the other code currently invoked here) to throw I think we should trap exceptions and not allow them to propagate from a C API.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Is there a reason why you do not throw SecurityCheckErrors with
> BOOST_THROW_EXCEPTION?

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> > Is there a reason why you do not throw SecurityCheckErrors with
> > BOOST_THROW_EXCEPTION?

Rats! the code changed while I was reading it.

review: Abstain
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> +MirCookie const* mir_cookie_from_buffer(void const* buffer, size_t size)
> +{
> + if (size != mir::cookie::default_blob_size)
> + return NULL;
> +
> + return new MirCookie(buffer, size);
> +}
>
> While it is extremely unlikely for operator new() (or any of the other code
> currently invoked here) to throw I think we should trap exceptions and not
> allow them to propagate from a C API.

Fixed!

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3287
https://mir-jenkins.ubuntu.com/job/mir-ci/137/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/137/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/137/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I've looked at this code too many times today to approve it. I'm not seeing what is there anymore.

review: Abstain
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3289
https://mir-jenkins.ubuntu.com/job/mir-ci/138/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/138/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/138/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

A first pass:

+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);

The name 'create_saving' is not very clear.

+ std::copy_n(std::begin(cookie), cookie.size(), std::begin(kev.cookie));

The code as written could overflow the kev.cookie array.

+#include "../mir_cookie.h"

We generally try to avoid pulling headers from parent directories (but it's not a dealbreaker, and it seems we are doing it more on the client side).

review: Needs Fixing
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3290
https://mir-jenkins.ubuntu.com/job/mir-ci/139/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/139/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/139/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3291
https://mir-jenkins.ubuntu.com/job/mir-ci/141/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/141/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/141/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3285
http://jenkins.qa.ubuntu.com/job/mir-ci/6111/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5662
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4569
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5618
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/326
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/435
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/435/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/435
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/435/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5615
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5615/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8053
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26968
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/322
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/322/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/178
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26976

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6111/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3292
https://mir-jenkins.ubuntu.com/job/mir-ci/142/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/142/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/142/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3293
https://mir-jenkins.ubuntu.com/job/mir-ci/143/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/143/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/143/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3294
https://mir-jenkins.ubuntu.com/job/mir-ci/144/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/144/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/144/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3296
https://mir-jenkins.ubuntu.com/job/mir-ci/145/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/145/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/145/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3296
http://jenkins.qa.ubuntu.com/job/mir-ci/6117/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5672
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4579
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5628
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/329
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/441
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/441/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/441
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/441/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5625
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5625/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8060
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26990
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/325
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/325/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/181
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/26991

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6117/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

ok you resolved everything i saw in this or the upcoming MP

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

@"* I guess gcc 4.* assume const for auto = make_unique<..> which causes issues when attempting to return a derived class to a base class. You cannot return a const unique_ptr since it cannot be std::moved"

I guess you're wrong: that would make auto support implausibly broken.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

+ * NULL will be returned if the buffer and size dont describe

s/dont/don't/

~~~~

+ * Construction function used to create a Authority. The secret size must be

s/a Authority/an Authority/

~~~~

+ // TODO Soon to be removed!
+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);

Why?

~~~~

 /// Sets an override functor for creating the cookie factory.

s/factory/authority/

~~~~

+ mir::cookie::Blob copy_vector_to_cookie_blob(std::vector<uint8_t> const& vector)

It's local to the TU, so I wouldn't block, but I'd reserve "copy" for functions that take a target. I'd call it something like "as_blob".

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

This introduces a number of FIXME/TODO comments, without it being clear when or why they will addressed.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> This introduces a number of FIXME/TODO comments, without it being clear when
> or why they will addressed.

All removed in this branch:
https://code.launchpad.net/~mir-team/mir/160-bit-finally/+merge/283751

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> @"* I guess gcc 4.* assume const for auto = make_unique<..> which causes
> issues when attempting to return a derived class to a base class. You cannot
> return a const unique_ptr since it cannot be std::moved"
>
> I guess you're wrong: that would make auto support implausibly broken.

Re looking at the compiler error... just looks like problem with implicit conversions? Not sure how removing the auto fixed it for me now though :(
https://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4576/console

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

> + * NULL will be returned if the buffer and size dont describe
>
> s/dont/don't/
>
> ~~~~
Fixing

>
> + * Construction function used to create a Authority. The secret size must be
>
> s/a Authority/an Authority/
>
> ~~~~
Fixing

>
> + // TODO Soon to be removed!
> + static std::unique_ptr<Authority> create_saving(Secret& save_secret);
>
> Why?
>
> ~~~~
Hmm that fixme shouldnt be there anymore? The reason was because we were going to create a lazy creation method for the secret. So we didnt depend on it on boot. Which ill be making a branch soon for that even though we've a work around in USC for the moment.
>
> /// Sets an override functor for creating the cookie factory.
>
> s/factory/authority/
>
> ~~~~
Fixing.
>
> + mir::cookie::Blob copy_vector_to_cookie_blob(std::vector<uint8_t> const&
> vector)
>
> It's local to the TU, so I wouldn't block, but I'd reserve "copy" for
> functions that take a target. I'd call it something like "as_blob".

Sounds good, fixing!

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

>+ // TODO Soon to be removed!
>+ static std::unique_ptr<Authority> create_saving(Secret& save_secret);
>
>Why?

Opps its a TODO, and yeah removed that this branch no need to have that TODO, and ill be address it very soon!

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3297
https://mir-jenkins.ubuntu.com/job/mir-ci/151/
Executed test runs:
    None: https://mir-jenkins.ubuntu.com/job/generic-update-mp/151/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/151/rebuild

review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:3297
http://jenkins.qa.ubuntu.com/job/mir-ci/6123/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-android-vivid-i386-build/5678
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-clang-vivid-amd64-build/4585
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-vivid-touch/5634
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-xenial-touch/332
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/447
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-amd64-ci/447/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/447
        deb: http://jenkins.qa.ubuntu.com/job/mir-xenial-i386-ci/447/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5631
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-vivid-armhf/5631/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-touch/8066
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27011
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/328
        deb: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-builder-xenial-armhf/328/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-mediumtests-runner-xenial-touch/184
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27017

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/mir-ci/6123/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Doc fixes have been applied.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

^-Network hiccup

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches