diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 22:00:51 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 22:00:51 +0000 |
commit | 6de0bcf0025517c4f31eafce162d90588c609103 (patch) | |
tree | 8ae27ceda2696e65a7b6d7b2d6a5474811914d88 /chrome/common | |
parent | 87ef23a2a8a693c9452ddf5c65d47c9fd62e032f (diff) | |
download | chromium_src-6de0bcf0025517c4f31eafce162d90588c609103.zip chromium_src-6de0bcf0025517c4f31eafce162d90588c609103.tar.gz chromium_src-6de0bcf0025517c4f31eafce162d90588c609103.tar.bz2 |
Fixes a race condition when a shared worker exits while one parent is loading
it.
Changed the shared worker startup code to assign a route ID at the time that we
initially lookup the worker, and pass that same route ID in when we later try
to create the worker, to gracefully handle this race condition.
BUG=29243
TEST=existing tests suffice (can't reproduce race condition in tests)
Review URL: http://codereview.chromium.org/600103
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/render_messages.h | 10 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 14 |
2 files changed, 16 insertions, 8 deletions
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 257d87e..533c92d 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -551,6 +551,10 @@ struct ViewHostMsg_CreateWorker_Params { // RenderView routing id used to send messages back to the parent. int render_view_route_id; + + // The route ID to associate with the worker. If MSG_ROUTING_NONE is passed, + // a new unique ID is created and assigned to the worker. + int route_id; }; // Creates a new view via a control message since the view doesn't yet exist. @@ -2401,6 +2405,7 @@ struct ParamTraits<ViewHostMsg_CreateWorker_Params> { WriteParam(m, p.name); WriteParam(m, p.document_id); WriteParam(m, p.render_view_route_id); + WriteParam(m, p.route_id); } static bool Read(const Message* m, void** iter, param_type* p) { return @@ -2408,7 +2413,8 @@ struct ParamTraits<ViewHostMsg_CreateWorker_Params> { ReadParam(m, iter, &p->is_shared) && ReadParam(m, iter, &p->name) && ReadParam(m, iter, &p->document_id) && - ReadParam(m, iter, &p->render_view_route_id); + ReadParam(m, iter, &p->render_view_route_id) && + ReadParam(m, iter, &p->route_id); } static void Log(const param_type& p, std::wstring* l) { l->append(L"("); @@ -2422,6 +2428,8 @@ struct ParamTraits<ViewHostMsg_CreateWorker_Params> { l->append(L", "); LogParam(p.render_view_route_id, l); l->append(L")"); + LogParam(p.route_id, l); + l->append(L")"); } }; diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 00cf0ed..68a209a 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1843,17 +1843,17 @@ IPC_BEGIN_MESSAGES(ViewHost) int /* route_id */) // This message is sent to the browser to see if an instance of this shared - // worker already exists (returns route_id != MSG_ROUTING_NONE). This route - // id can be used to forward messages to the worker via ForwardToWorker. If a + // worker already exists. If so, it returns exists == true. If a // non-empty name is passed, also validates that the url matches the url of // the existing worker. If a matching worker is found, the passed-in // document_id is associated with that worker, to ensure that the worker // stays alive until the document is detached. - IPC_SYNC_MESSAGE_CONTROL4_2(ViewHostMsg_LookupSharedWorker, - GURL /* url */, - string16 /* name */, - unsigned long long /* document_id */, - int /* render_view_route_id */, + // The route_id returned can be used to forward messages to the worker via + // ForwardToWorker if it exists, otherwise it should be passed in to any + // future call to CreateWorker to avoid creating duplicate workers. + IPC_SYNC_MESSAGE_CONTROL1_3(ViewHostMsg_LookupSharedWorker, + ViewHostMsg_CreateWorker_Params, + bool /* exists */, int /* route_id */, bool /* url_mismatch */) |