Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Issue 2677013003: Add an Implementations class (Closed)

Created:
3 years, 10 months ago by cco3
Modified:
3 years, 9 months ago
Reviewers:
Maria
CC:
chromium-reviews, agrieve+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Add an Implementations class This class provides a static create() method that allows client code to generate a class appropriate to the running build. This is superior to the current approach, which requires a ChromeApplication, which may not always be available. To use this create() method, one needs to: - give the upstream class a public parameterless constructor, - give the downstream class a public parameterless constructor, - register the downstream class in the downstream Implementations getClass() method, and - invoke this method on the appropriate class (e.g., Implementations.create(MyType.class)). In order to pull this off, an ImplementationsMetadata is built into the package depending on whether or not the downstream should be responsible for constructing the Implementations instance. BUG=685383

Patch Set 1 #

Patch Set 2 : Use LazyHolder idiom #

Patch Set 3 : Simplify the approach #

Unified diffs Side-by-side diffs Delta from patch set Stats (+76 lines, -0 lines) Patch
A chrome/android/java/src/org/chromium/chrome/browser/Implementations.java View 1 2 1 chunk +75 lines, -0 lines 0 comments Download
M chrome/android/java_sources.gni View 1 2 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 10 (2 generated)
cco3
Hi Maria. I decided to practice some dark art with the build system to pull ...
3 years, 10 months ago (2017-02-06 19:16:18 UTC) #2
Maria
On 2017/02/06 19:16:18, cco3 wrote: > Hi Maria. I decided to practice some dark art ...
3 years, 10 months ago (2017-02-06 20:19:34 UTC) #3
cco3
On 2017/02/06 20:19:34, Maria wrote: > On 2017/02/06 19:16:18, cco3 wrote: > > Hi Maria. ...
3 years, 10 months ago (2017-02-06 21:27:14 UTC) #4
cco3
Adding aberent@,
3 years, 10 months ago (2017-02-06 21:27:33 UTC) #5
aberent
On 2017/02/06 21:27:33, cco3 wrote: > Adding aberent@, I think this resolves my original concerns. ...
3 years, 10 months ago (2017-02-07 10:36:30 UTC) #6
cco3
Note that I could also accomplish this by attempting to load a downstream class at ...
3 years, 10 months ago (2017-02-07 18:23:37 UTC) #7
cco3
On 2017/02/07 18:23:37, cco3 wrote: > Note that I could also accomplish this by attempting ...
3 years, 10 months ago (2017-02-07 19:35:56 UTC) #8
Maria
3 years, 10 months ago (2017-02-10 19:57:32 UTC) #9
On 2017/02/07 19:35:56, cco3 wrote:
> On 2017/02/07 18:23:37, cco3 wrote:
> > Note that I could also accomplish this by attempting to load a downstream
> class
> > at build time (by its specific downstream name).  This would remove build
> > trickery.  I'll upload a patchset with that approach and you all can tell me
> if
> > it's still to complicated.
> 
> Alright, here's a simpler approach.

So, here's how I am thinking about this:

Pros:
 - Fewer methods on ChromeApplication/ChromeApplicationInternal classes
 - Removes ChromeApplication casting from a bunch of callers

Cons:
 - A fair bit harder to understand how the mechanism works
 - Slower (reflection is slow and try/catch is also slow)

- Not quite sure where this falls in LOC added/removed. Probably pretty close,
given that the new impl is 100+ lines (upstream + downstream).

Right now I am not 100% convinced pros outweigh the cons. Maybe I am not
thinking about some advantages of this approach that you see?

Powered by Google App Engine
This is Rietveld 408576698